## Curves ### Curve Utility abstract class for manipulating curves. - new Curve\() - .isCurve: `true` - [.arcLengthDivisions](#curve-arc-length-divisions): `number` - [.needsUpdate](#curve-needs-update): `boolean` - [.getPoint(t)](#curve-get-point-method): `V` - [.getPointAt(u)](#curve-get-point-at-method): `V` - [.getPoints(divisions?)](#curve-get-points-method): `V[]` - [.getSpacedPoints(divisions?)](#curve-get-spaced-points-method): `V[]` - [.getLength()](#curve-get-length-method): `number` - [.getLengths(divisions?)](#curve-get-lengths-method): `number[]` - [.updateArcLengths()](#curve-update-arc-lengths-method): `void` - [.getUtoTmapping(t, targetArcLength?)](#curve-get-u-to-t-mapping-method): `number` - [.getTangent(t)](#curve-get-tangent-method): `V` - [.getTangentAt(u)](#curve-get-tangent-at-method): `V` - [.isClosed()](#curve-is-closed-method): `boolean` #### Properties ##### .`arcLengthDivisions` Amount of divisions when calculating the cumulative segment lengths of a curve. ```ts Curve.arcLengthDivisions: number; ``` ##### .`needsUpdate` Must be set to `true` if the curve parameters have changed. ```ts Curve.needsUpdate: boolean; ``` #### Methods ##### .`getPoint(t)` Interpolate a point on the curve. - `u`: Normalized time value to interpolate. ```ts Curve.getPoint(t: number): V; ``` ##### .`getPointAt(u)` Interpolate a point on the curve. - `u`: Normalized position value to interpolate. ```ts Curve.getPointAt(u: number): V; ``` ##### .`getPoints(divisions?)` Compute the curve shape into an array of points. - `[divisions=5]`: Number of divisions. ```ts Curve.getPoints(divisions?: number): V[]; ``` ##### .`getSpacedPoints(divisions?)` Compute the curve shape into an array of equi-spaced points across the entire curve. - `[divisions=5]`: Number of divisions. ```ts Curve.getSpacedPoints(divisions?: number): V[]; ``` ##### .`getLength()` Compute the total arc length of the curve. ```ts Curve.getLength(): number; ``` ##### .`getLengths(divisions?)` Compute the cumulative segment lengths of the curve. - `[divisions]`: Number of divisions. ```ts Curve.getLengths(divisions?: number): number[]; ``` ##### .`updateArcLengths()` Update the cached cumulative segment lengths. ```ts Curve.updateArcLengths(): void; ``` ##### .`getUtoTmapping(t, targetArcLength?)` Re-map a normalized position value into normalized time. - `u`: Normalized position value to interpolate. - `[targetArcLength]`: Distance on the curve. ```ts Curve.getUtoTmapping(u: number, targetArcLength?: number): number; ``` ##### .`getTangent(t)` Compute an unit vector tangent for a given normalized time value. - `t`: Normalized time value. ```ts Curve.getTangent(t: number): V; ``` ##### .`getTangentAt(u)` Compute an unit vector tangent for a given normalized position value. - `u`: Normalized position value. ```ts Curve.getTangentAt(u: number): V; ``` ##### .`isClosed()` Check if the curve is closed. ```ts Curve.isClosed(): boolean; ``` ### LineCurve Utility class extending [Curve](#curve) for manipulating lines. - [new LineCurve(x1, y1, x2, y2)](#line-curve-constructor) - `static` [.interpolate(t, x1, y1, x2, y2)](#line-curve-static-interpolate-method): `[number, number]` #### Constructor | Parameter | Type | Default | Description | | --------- | -------- | ------- | ------------------------------------- | | x1 | `number` | | X-axis coordinate of the start point. | | y1 | `number` | | Y-axis coordinate of the start point. | | x2 | `number` | | X-axis coordinate of the end point. | | y2 | `number` | | Y-axis coordinate of the end point. | ##### `static` LineCurve.`interpolate(t, x1, y1, x2, y2)` Interpolate a point on a line. ```ts static LineCurve.interpolate( t: number, x1: number, y1: number, x2: number, y2: number ): [number, number]; ``` ### LineCurve3 Utility class extending [Curve](#curve) for manipulating 3D lines. - [new LineCurve3(x1, y1, z1, x2, y2, z2)](#line-curve-3-constructor) - `static` [.interpolate(t, x1, y1, z1, x2, y2, z2)](#line-curve-3-static-interpolate-method): `[number, number, number]` #### Constructor | Parameter | Type | Default | Description | | --------- | -------- | ------- | ------------------------------------- | | x1 | `number` | | X-axis coordinate of the start point. | | y1 | `number` | | Y-axis coordinate of the start point. | | z1 | `number` | | Z-axis coordinate of the start point. | | x2 | `number` | | X-axis coordinate of the end point. | | y2 | `number` | | Y-axis coordinate of the end point. | | z2 | `number` | | Z-axis coordinate of the end point. | ##### `static` LineCurve3.`interpolate(t, x1, y1, z1, x2, y2, z2)` Interpolate a point on a 3D line. ```ts static LineCurve3.interpolate( t: number, x1: number, y1: number, z1: number, x2: number, y2: number, z2: number ): [number, number, number]; ``` ### PolylineCurve Utility class extending [Curve](#curve) for manipulating polylines. - [new PolylineCurve(points?)](#polyline-curve-constructor) #### Constructor | Parameter | Type | Default | Description | | --------- | ------------------------- | ------- | ----------------------------------- | | [points] | `Array<[number, number]>` | `[]` | Array of points defining the curve. | ### PolylineCurve3 Utility class extending [Curve](#curve) for manipulating 3D polylines. - [new PolylineCurve3(points?)](#polyline-curve-3-constructor) #### Constructor | Parameter | Type | Default | Description | | --------- | --------------------------------- | ------- | ----------------------------------- | | [points] | `Array<[number, number, number]>` | `[]` | Array of points defining the curve. | ### QuadraticBezierCurve Utility class extending [Curve](#curve) for manipulating Quadratic Bézier curves. - [new QuadraticBezierCurve(x1, y1, cpx, cpy, x2, y2)](#quadratic-bezier-curve-constructor) - `static` [.interpolate(t, x1, y1, cpx, cpy, x2, y2)](#quadratic-bezier-curve-static-interpolate-method): `[number, number]` #### Constructor | Parameter | Type | Default | Description | | --------- | -------- | ------- | --------------------------------------- | | x1 | `number` | | X-axis coordinate of the start point. | | y1 | `number` | | Y-axis coordinate of the start point. | | cpx | `number` | | X-axis coordinate of the control point. | | cpy | `number` | | Y-axis coordinate of the control point. | | x2 | `number` | | X-axis coordinate of the end point. | | y2 | `number` | | Y-axis coordinate of the end point. | ##### `static` QuadraticBezierCurve.`interpolate(t, x1, y1, cpx, cpy, x2, y2)` Interpolate a point on a 2D Quadratic Bézier curve. ```ts static QuadraticBezierCurve.interpolate( t: number, x1: number, y1: number, cpx: number, cpy: number, x2: number, y2: number ): [number, number]; ``` ### QuadraticBezierCurve3 Utility class extending [Curve](#curve) for manipulating Quadratic Bézier 3D curves. - [new QuadraticBezierCurve3(x1, y1, z1, cpx, cpy, cpz, x2, y2, z2)](#quadratic-bezier-curve-3-constructor) - `static` [.interpolate(t, x1, y1, z1, cpx, cpy, cpz, x2, y2, z2)](#quadratic-bezier-curve-3-static-interpolate-method): `[number, number, number]` #### Constructor | Parameter | Type | Default | Description | | --------- | -------- | ------- | --------------------------------------- | | x1 | `number` | | X-axis coordinate of the start point. | | y1 | `number` | | Y-axis coordinate of the start point. | | z1 | `number` | | Z-axis coordinate of the start point. | | cpx | `number` | | X-axis coordinate of the control point. | | cpy | `number` | | Y-axis coordinate of the control point. | | cpz | `number` | | Z-axis coordinate of the control point. | | x2 | `number` | | X-axis coordinate of the end point. | | y2 | `number` | | Y-axis coordinate of the end point. | | z2 | `number` | | Z-axis coordinate of the end point. | ##### `static` QuadraticBezierCurve3.`interpolate(t, x1, y1, z1, cpx, cpy, cpz, x2, y2, z2)` Interpolate a point on a 3D Quadratic Bézier curve. ```ts static QuadraticBezierCurve3.interpolate( t: number, x1: number, y1: number, z1: number, cpx: number, cpy: number, cpz: number, x2: number, y2: number, z2: number ): [number, number, number]; ``` ### CubicBezierCurve Utility class extending [Curve](#curve) for manipulating Cubic Bézier curves. - [new CubicBezierCurve(x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2)](#cubic-bezier-curve-constructor) - `static` [.interpolate(t, x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2)](#cubic-bezier-curve-static-interpolate-method): `[number, number]` #### Constructor | Parameter | Type | Default | Description | | --------- | -------- | ------- | ---------------------------------------------- | | x1 | `number` | | X-axis coordinate of the start point. | | y1 | `number` | | Y-axis coordinate of the start point. | | cp1x | `number` | | X-axis coordinate of the first control point. | | cp1y | `number` | | Y-axis coordinate of the first control point. | | cp2x | `number` | | X-axis coordinate of the second control point. | | cp2y | `number` | | Y-axis coordinate of the second control point. | | x2 | `number` | | X-axis coordinate of the end point. | | y2 | `number` | | Y-axis coordinate of the end point. | ##### `static` CubicBezierCurve.`interpolate(t, x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2)` Interpolate a point on a 2D Cubic Bézier curve. ```ts static CubicBezierCurve.interpolate( t: number, x1: number, y1: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number ): [number, number]; ``` ### CubicBezierCurve3 Utility class extending [Curve](#curve) for manipulating Cubic Bézier 3D curves. - [new CubicBezierCurve3(x1, y1, z1, cp1x, cp1y, cp1z, cp2x, cp2y, cp2z, x2, y2, z2)](#cubic-bezier-curve-3-constructor) - `static` [.interpolate(t, x1, y1, z1, cp1x, cp1y, cp1z, cp2x, cp2y, cp2z, x2, y2, z2)](#cubic-bezier-curve-3-static-interpolate-method): `[number, number, number]` #### Constructor | Parameter | Type | Default | Description | | --------- | -------- | ------- | ---------------------------------------------- | | x1 | `number` | | X-axis coordinate of the start point. | | y1 | `number` | | Y-axis coordinate of the start point. | | z1 | `number` | | Z-axis coordinate of the start point. | | cp1x | `number` | | X-axis coordinate of the first control point. | | cp1y | `number` | | Y-axis coordinate of the first control point. | | cp1z | `number` | | Z-axis coordinate of the first control point. | | cp2x | `number` | | X-axis coordinate of the second control point. | | cp2y | `number` | | Y-axis coordinate of the second control point. | | cp2z | `number` | | Z-axis coordinate of the second control point. | | x2 | `number` | | X-axis coordinate of the end point. | | y2 | `number` | | Y-axis coordinate of the end point. | | z2 | `number` | | Z-axis coordinate of the end point. | ##### `static` CubicBezierCurve3.`interpolate(t, x1, y1, z1, cp1x, cp1y, cp1z, cp2x, cp2y, cp2z, x2, y2, z2)` Interpolate a point on a 3D Cubic Bézier curve. ```ts static CubicBezierCurve3.interpolate( t: number, x1: number, y1: number, z1: number, cp1x: number, cp1y: number, cp1z: number, cp2x: number, cp2y: number, cp2z: number, x2: number, y2: number, z2: number ): [number, number, number]; ``` ### CatmullRomCurve Utility class extending [Curve](#curve) for manipulating Catmull-Rom curves. - [new CatmullRomCurve(x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2)](#catmull-rom-curve-constructor) - `static` [.interpolate(t, x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2)](#catmull-rom-curve-static-interpolate-method): `[number, number]` #### Constructor | Parameter | Type | Default | Description | | --------- | -------- | ------- | ---------------------------------------------- | | x1 | `number` | | X-axis coordinate of the start point. | | y1 | `number` | | Y-axis coordinate of the start point. | | cp1x | `number` | | X-axis coordinate of the first control point. | | cp1y | `number` | | Y-axis coordinate of the first control point. | | cp2x | `number` | | X-axis coordinate of the second control point. | | cp2y | `number` | | Y-axis coordinate of the second control point. | | x2 | `number` | | X-axis coordinate of the end point. | | y2 | `number` | | Y-axis coordinate of the end point. | ##### `static` CatmullRomCurve.`interpolate(t, x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2)` Interpolate a point on a 2D Catmull-Rom spline. ```ts static CatmullRomCurve.interpolate( t: number, x1: number, y1: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number ): [number, number]; ``` ### CatmullRomCurve3 Utility class extending [Curve](#curve) for manipulating Catmull-Rom 3D curves. - [new CatmullRomCurve3(x1, y1, z1, cp1x, cp1y, cp1z, cp2x, cp2y, cp2z, x2, y2, z2)](#catmull-rom-curve-3-constructor) - `static` [.interpolate(t, x1, y1, z1, cp1x, cp1y, cp1z, cp2x, cp2y, cp2z, x2, y2, z2)](#catmull-rom-curve-3-static-interpolate-method): `[number, number, number]` #### Constructor | Parameter | Type | Default | Description | | --------- | -------- | ------- | ---------------------------------------------- | | x1 | `number` | | X-axis coordinate of the start point. | | y1 | `number` | | Y-axis coordinate of the start point. | | z1 | `number` | | Z-axis coordinate of the start point. | | cp1x | `number` | | X-axis coordinate of the first control point. | | cp1y | `number` | | Y-axis coordinate of the first control point. | | cp1z | `number` | | Z-axis coordinate of the first control point. | | cp2x | `number` | | X-axis coordinate of the second control point. | | cp2y | `number` | | Y-axis coordinate of the second control point. | | cp2z | `number` | | Z-axis coordinate of the second control point. | | x2 | `number` | | X-axis coordinate of the end point. | | y2 | `number` | | Y-axis coordinate of the end point. | | z2 | `number` | | Z-axis coordinate of the end point. | ##### `static` CatmullRomCurve3.`interpolate(t, x1, y1, z1, cp1x, cp1y, cp1z, cp2x, cp2y, cp2z, x2, y2, z2)` Interpolate a point on a 3D Catmull-Rom spline. ```ts static CatmullRomCurve3.interpolate( t: number, x1: number, y1: number, z1: number, cp1x: number, cp1y: number, cp1z: number, cp2x: number, cp2y: number, cp2z: number, x2: number, y2: number, z2: number ): [number, number, number]; ``` ### SplineCurve Utility class extending [Curve](#curve) for manipulating splines. - [new SplineCurve(points?)](#spline-curve-constructor) #### Constructor | Parameter | Type | Default | Description | | --------- | ------------------------- | ------- | ----------------------------------- | | [points] | `Array<[number, number]>` | `[]` | Array of points defining the curve. | ### SplineCurve3 Utility class extending [Curve](#curve) for manipulating 3D splines. - [new SplineCurve3(points?)](#spline-curve-3-constructor) #### Constructor | Parameter | Type | Default | Description | | --------- | --------------------------------- | ------- | ----------------------------------- | | [points] | `Array<[number, number, number]>` | `[]` | Array of points defining the curve. | ### EllipseCurve Utility class extending [Curve](#curve) for manipulating ellipses. - [new EllipseCurve(cx, cy, rx, ry, rotation?, startAngle?, endAngle?, counterclockwise?)](#ellipse-curve-constructor) - `static` [.interpolate(t, cx, cy, rx, ry, rotation?, startAngle?, endAngle?, counterclockwise?)](#ellipse-curve-static-interpolate-method): `[number, number]` #### Constructor | Parameter | Type | Default | Description | | ------------------ | --------- | -------- | -------------------------------------------------------------------------------------- | | cx | `number` | | X-axis coordinate of the center of the ellipse. | | cy | `number` | | Y-axis coordinate of the center of the ellipse. | | rx | `number` | | X-radius of the ellipse. | | ry | `number` | | Y-radius of the ellipse. | | [rotation] | `number` | `0` | Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis. | | [startAngle] | `number` | `0` | Start angle of the arc (in radians). | | [endAngle] | `number` | `2 * PI` | End angle of the arc (in radians). | | [counterclockwise] | `boolean` | `false` | Flag indicating the direction of the arc. | ##### `static` EllipseCurve.`interpolate(t, cx, cy, rx, ry, rotation, startAngle, endAngle, counterclockwise)` Interpolate a point on an elliptical arc. ```ts static EllipseCurve.interpolate( t: number, cx: number, cy: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean ): [number, number]; ``` ### ArcCurve Utility class extending [EllipseCurve](#ellipse-curve) for manipulating arcs. - [new ArcCurve(cx, cy, radius, startAngle?, endAngle?, counterclockwise?)](#arc-curve-constructor) #### Constructor | Parameter | Type | Default | Description | | ------------------ | --------- | -------- | ---------------------------------------------- | | cx | `number` | | X-axis coordinate of the center of the circle. | | cy | `number` | | Y-axis coordinate of the center of the circle. | | radius | `number` | | X-radius of the circle. | | [startAngle] | `number` | `0` | Start angle of the arc (in radians). | | [endAngle] | `number` | `2 * PI` | End angle of the arc (in radians). | | [counterclockwise] | `boolean` | `false` | Flag indicating the direction of the arc. |