Create a new interpolator instance
control points
curve interpolator options
Private
_invalidateInvalidates/clears cache
Create and cache a lookup table of n=samples points, indexed by position (u)
Map of positions -> points
function generating lookup table value
number of samples (segments)
Optional
options: { object of { from, to, cacheKey } - if cacheKey is included, the map will be stored in the internal cache
Optional
cacheOptional
cacheOptional
from?: numberOptional
to?: numberConvenience function for iterating over multiple values for a set of samples along the curve. The forEach function takes a user defined callback function, which will be called for each position along the curve with its position (u), time (t), sample index (i) and the previous mapped value (prev)
array of mapped objects
callback function
number of (evenly spaced) samples OR an array of user specified positions (u)
from position
to position
Finds the curvature and radius at the specified position (0..1) on the curve. The unsigned curvature is returned along with radius, tangent vector and, for 2D and 3D curves, a direction vector is included (which points toward the center of the curvature).
object containing the unsigned curvature, radius + tangent and direction vectors
position on curve (0 - 1)
Finds the curvature and radius at the specified time (0..1) on the curve. The unsigned curvature is returned along with radius, tangent vector and, for 2D and 3D curves, a direction vector is included (which points toward the center of the curvature).
object containing the unsigned curvature, radius + tangent and direction vectors
time (t) along curve (0 - 1)
Get the derivative at the given position.
position on curve (0 - 1)
optional target
Calculate the Frenet-Serret frames for a 3d curve, using the concept of parallel transport. The implementation used here is basically a copy of the function used in THREE.js (https://github.com/mrdoob/three.js), which in turn is based on the the paper "Parallel Transport Approach to Curve Framing" by Hanson and Ma (https://legacy.cs.indiana.edu/ftp/techreports/TR425.pdf)
In the case of 2d, the normals are rotated 90 degrees counter-clockwise from the tangents and the binormals are omitted.
object containing arrays for tangents, normals and binormals if applicable
number of samples (segments) along the curve (will return segments + 1 frames)
position from
position to
Find points on the curve intersecting a specific value along a given axis. The axis is given as an index from 0 - n, i.e. 0 = x-axis, 1 = y-axis, 2 = z-axis etc.
The max parameter is used to specify the maximum number of solutions you want returned, where max=0 returns all solutions and a negative number will return the max number of solutions starting from the end of the curve and a positive number starting from the beginning of the curve. Note that If max = 1 or -1, this function returns the point (unwrapped) or null if no intersects exist. In any other case an array will be returned, regardless of there's multiple, a single or no solutions.
lookup value
index of axis [0=x, 1=y, 2=z ...]
max solutions (i.e. 0=all, 1=first along curve, -1=last along curve)
Find positions (0-1) on the curve intersected by the given value along a given axis
lookup value
index of axis [0=x, 1=y, 2=z ...]
max solutions (i.e. 0=all, 1=first along curve, -1=last along curve)
Find intersects as time (0-1) on the curve intersected by the given value along a given axis
lookup value
index of axis [0=x, 1=y, 2=z ...]
max solutions (i.e. 0=all, 1=first along curve, -1=last along curve)
Get the nearest position on the curve from a point. This is an approximation and its accuracy is determined by the threshold value (smaller number requires more passes but is more precise)
Object with position (u), distance and the point at u/t
Vector
Precision
Optional
samples: numberGet the normal for 2D or 3D curve at the given position. In 3D the normal points towards the center of the curvature.
position on curve (0 - 1)
optional target
Get the normal for 2D or 3D curve at the given time (t). In 3D the normal points towards the center of the curvature.
time at curve (0 - 1)
optional target
Interpolate a point at the given position.
position on curve (0..1)
optional target
Get the point along the curve corresponding to the value of t (time along curve) This function is only useful when you need to address the curve by time, where time will vary depending on segment length and curvature. To address the curve normalized for length (constant speed and uniform spacing), use the getPointAt function instead.
position as vector
time along full curve (encodes segment index and segment t)
Optional
target: VectorTypeoptional target vector
Get uniformly sampled points along the curve. Returns samples + 1 points.
number of samples (segments)
optional return type
Get the second derivative at the given position.
position on curve (0 - 1)
optional target
Get the tangent at the given position.
position on curve (0 - 1)
optional target
Get the tangent at the given time.
time at curve (0 - 1)
optional target
Returns the time on curve at a position, given as a value between 0 and 1
position on curve (0..1)
whether the input value should be clamped to a valid range or not
Convenience function for returning multiple values for a set of samples along the curve. The map function takes a user defined mapping function, which will be called for each position along the curve with its position (u), time (t), sample index (i) and the previous mapped value (prev)
array of mapped objects
mapping function
number of (evenly spaced) samples OR an array of user specified positions (u)
from position
to position
Convenience function for reducing multiple values for a set of samples along the curve. This function takes a user defined reduce function, which will be called for each position along the curve with its position (u), time (t), sample index (i) and the previous mapped value (prev)
array of mapped objects
reduce function
initial accumulator value
number of (evenly spaced) samples OR an array of user specified positions (u)
from position
to position
Generated using TypeDoc
Cubic curve interpolator