UNPKG

@mlightcad/geometry-engine

Version:

The geometry-engine package provides comprehensive geometric entities, mathematical operations, and transformations for 2D and 3D space. This package mimics AutoCAD ObjectARX's AcGe (Geometry) classes and provides the mathematical foundation for CAD opera

146 lines 4.25 kB
import { AcGeBox3d, AcGeMatrix3d, AcGePoint3d, AcGePoint3dLike } from '../math'; import { AcGeCurve3d } from './AcGeCurve3d'; /** * Centripetal CatmullRom Curve - which is useful for avoiding * cusps and self-intersections in non-uniform catmull rom curves. * http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf * * curve.type accepts centripetal(default), chordal and catmullrom * curve.tension is used for catmullrom which defaults to 0.5 */ /** * Type for curve interpolation methods */ export type CatmullRomCurveType = 'centripetal' | 'chordal' | 'catmullrom'; /** * A curve representing a Catmull-Rom spline. * * ```js * //Create a closed wavey loop * const curve = new AcGeCatmullRomCurve3d( [ * new AcGePoint3d( -10, 0, 10 ), * new AcGePoint3d( -5, 5, 5 ), * new AcGePoint3d( 0, 0, 0 ), * new AcGePoint3d( 5, -5, 5 ), * new AcGePoint3d( 10, 0, 10 ) * ], true ); // true for closed curve * * const points = curve.getPoints( 50 ); * * // Convert to NURBS curve * const nurbsCurve = curve.toNurbsCurve(); * ``` */ export declare class AcGeCatmullRomCurve3d extends AcGeCurve3d { /** * This flag can be used for type testing. */ readonly isCatmullRomCurve3d = true; /** * The curve type identifier */ readonly type = "CatmullRomCurve3d"; /** * An array of 3D points defining the curve. */ private _points; /** * Whether the curve is closed or not. */ private _closed; /** * The curve type. */ private _curveType; /** * Tension of the curve. */ private _tension; private readonly _tmp; private readonly _px; private readonly _py; private readonly _pz; /** * Constructs a new Catmull-Rom curve. * * @param points - An array of 3D points defining the curve. * @param closed - Whether the curve is closed or not. * @param curveType - The curve type. * @param tension - Tension of the curve. */ constructor(points?: AcGePoint3dLike[], closed?: boolean, curveType?: CatmullRomCurveType, tension?: number); /** * An array of 3D points defining the curve. */ get points(): AcGePoint3d[]; /** * Whether the curve is closed or not. */ get closed(): boolean; /** * The curve type. */ get curveType(): CatmullRomCurveType; /** * Tension of the curve. */ get tension(): number; /** * Start point of this curve. */ get startPoint(): AcGePoint3d; /** * End point of this curve. */ get endPoint(): AcGePoint3d; /** * Length of this curve (approximated). */ get length(): number; /** * Returns a point on the curve. * * @param t - A interpolation factor representing a position on the curve. Must be in the range `[0,1]`. * @param optionalTarget - The optional target vector the result is written to. * @return The position on the curve. */ getPoint(t: number, optionalTarget?: AcGePoint3d): AcGePoint3d; /** * Get an array of points along the curve * @param divisions - Number of divisions to create * @returns Array of points along the curve */ getPoints(divisions: number): AcGePoint3d[]; /** * Set the points defining the curve * @param points - Array of points */ setPoints(points: AcGePoint3dLike[]): void; /** * Set whether the curve is closed * @param closed - Whether the curve should be closed */ setClosed(closed: boolean): void; /** * Set the curve type * @param curveType - The curve type */ setCurveType(curveType: CatmullRomCurveType): void; /** * Set the tension of the curve * @param tension - The tension value */ setTension(tension: number): void; /** * Transforms the curve by applying the input matrix. * @param matrix Input transformation matrix * @return Return this curve */ transform(matrix: AcGeMatrix3d): this; /** * Calculate the bounding box of this curve. * @return The bounding box */ protected calculateBoundingBox(): AcGeBox3d; } //# sourceMappingURL=AcGeCatmullRomCurve3d.d.ts.map