UNPKG

@bitbybit-dev/base

Version:

Bit By Bit Developers Base CAD Library to Program Geometry

150 lines (149 loc) 5.63 kB
import { GeometryHelper } from "./geometry-helper"; import * as Inputs from "../inputs"; import { Point } from "./point"; import { Vector } from "./vector"; import { Line } from "./line"; /** * Contains various methods for polyline. Polyline in bitbybit is a simple object that has points property containing an array of points. * { points: number[][] } */ export declare class Polyline { private readonly vector; private readonly point; private readonly line; private readonly geometryHelper; constructor(vector: Vector, point: Point, line: Line, geometryHelper: GeometryHelper); /** * Gets the length of the polyline * @param inputs a polyline * @returns length * @group get * @shortname polyline length * @drawable false */ length(inputs: Inputs.Polyline.PolylineDto): number; /** * Gets the number of points in the polyline * @param inputs a polyline * @returns nr of points * @group get * @shortname nr polyline points * @drawable false */ countPoints(inputs: Inputs.Polyline.PolylineDto): number; /** * Gets the points of the polyline * @param inputs a polyline * @returns points * @group get * @shortname points * @drawable true */ getPoints(inputs: Inputs.Polyline.PolylineDto): Inputs.Base.Point3[]; /** * Reverse the points of the polyline * @param inputs a polyline * @returns reversed polyline * @group convert * @shortname reverse polyline * @drawable true */ reverse(inputs: Inputs.Polyline.PolylineDto): Inputs.Polyline.PolylinePropertiesDto; /** * Transform the polyline * @param inputs a polyline * @returns transformed polyline * @group transforms * @shortname transform polyline * @drawable true */ transformPolyline(inputs: Inputs.Polyline.TransformPolylineDto): Inputs.Polyline.PolylinePropertiesDto; /** * Create the polyline * @param inputs points and info if its closed * @returns polyline * @group create * @shortname polyline * @drawable true */ create(inputs: Inputs.Polyline.PolylineCreateDto): Inputs.Polyline.PolylinePropertiesDto; /** * Create the lines from the polyline * @param inputs polyline * @returns lines * @group convert * @shortname polyline to lines * @drawable true */ polylineToLines(inputs: Inputs.Polyline.PolylineDto): Inputs.Base.Line3[]; /** * Create the segments from the polyline * @param inputs polyline * @returns segments * @group convert * @shortname polyline to segments * @drawable false */ polylineToSegments(inputs: Inputs.Polyline.PolylineDto): Inputs.Base.Segment3[]; /** * Finds the points of self intersection of the polyline * @param inputs points of self intersection * @returns polyline * @group intersections * @shortname polyline self intersections * @drawable true */ polylineSelfIntersection(inputs: Inputs.Polyline.PolylineToleranceDto): Inputs.Base.Point3[]; /** * Finds the intersection points between two polylines * @param inputs two polylines and tolerance * @returns points * @group intersection * @shortname two polyline intersection * @drawable true */ twoPolylineIntersection(inputs: Inputs.Polyline.TwoPolylinesToleranceDto): Inputs.Base.Point3[]; /** * Create the polylines from segments that are potentially connected but scrambled randomly * @param inputs segments * @returns polylines * @group sort * @shortname segments to polylines * @drawable true */ sortSegmentsIntoPolylines(inputs: Inputs.Polyline.SegmentsToleranceDto): Inputs.Base.Polyline3[]; /** * Calculates the maximum possible half-line fillet radius for each corner * of a given polyline. For a closed polyline, it includes the corners * connecting the last segment back to the first. * * The calculation uses the 'half-line' constraint, meaning the fillet's * tangent points must lie within the first half of each segment connected * to the corner. * * @param inputs Defines the polyline points, whether it's closed, and an optional tolerance. * @returns An array containing the maximum fillet radius calculated for each corner. * The order corresponds to corners P[1]...P[n-2] for open polylines, * and P[1]...P[n-2], P[0], P[n-1] for closed polylines. * Returns an empty array if the polyline has fewer than 3 points. * @group fillet * @shortname polyline max fillet radii * @drawable false */ maxFilletsHalfLine(inputs: Inputs.Polyline.PolylineToleranceDto): number[]; /** * Calculates the single safest maximum fillet radius that can be applied * uniformly to all corners of a polyline, based on the 'half-line' constraint. * This is determined by finding the minimum of the maximum possible fillet * radii calculated for each individual corner. * * @param inputs Defines the polyline points, whether it's closed, and an optional tolerance. * @returns The smallest value from the results of calculatePolylineMaxFillets. * Returns 0 if the polyline has fewer than 3 points or if any * calculated maximum radius is 0. * @group fillet * @shortname polyline safest fillet radius * @drawable false */ safestFilletRadius(inputs: Inputs.Polyline.PolylineToleranceDto): number; }