NurbsCurve
verb.geom.NurbsCurve
CLASS
A NURBS curve - this class represents the base class of many of verb.geom's curve types and provides many tools for analysis and evaluation.
This object is deliberately constrained to be immutable. The methods to inspect the properties of this class deliberately return copies. asNurbs
can
be used to obtain a simplified NurbsCurveData object that can be used with verb.core
or for serialization purposes.
Under the hood, this type takes advantage of verb's asynchronous runtime using the _Async methods. Calling one of these
methods returns a Promise
instead of the value. This allows you to run the computation in a background thread and obtain the value asynchronously.
You can find further documentation for using Promise
's at https://github.com/jdonaldson/promhx.
Extends: SerializableBase
Implements: ICurve
constructor
METHOD
new NurbsCurve(data : NurbsCurveData)
Construct a NurbsCurve by a NurbsCurveData object
params
- The data object
returns
- A new NurbsCurve
byKnotsControlPointsWeights
STATIC METHOD
byKnotsControlPointsWeights(degree : Int, knots : KnotArray, controlPoints : Array<Point>, weights : Array<Float>) : NurbsCurve
Construct a NurbsCurve by degree, knots, control points, weights
params
- The degree
- The knot array
- Array of control points
- Array of weight values
returns
- A new NurbsCurve
byPoints
STATIC METHOD
byPoints(points : Array<Point>, degree : Int) : NurbsCurve
Construct a NurbsCurve by interpolating a collection of points. The resultant curve will pass through all of the points.
params
- An array of points
- Optional : The degree of resultant curve
returns
- A new NurbsCurve
degree
METHOD
degree() : Int
The degree of the curve
knots
METHOD
knots() : KnotArray
The knot array
controlPoints
METHOD
controlPoints() : Array<Point>
Array of control points
weights
METHOD
weights() : Array<Float>
Array of weight values
asNurbs
METHOD
asNurbs() : NurbsCurveData
Obtain a copy of the underlying data structure for the Curve. Used with verb.core.
returns
- A new NurbsCurveData object
clone
METHOD
clone()
Obtain a copy of the curve
returns
- The copied curve
domain
METHOD
domain() : Interval<Float>
Determine the valid domain of the curve
returns
- An array representing the high and end point of the domain of the curve
transform
METHOD
transform(mat : Matrix) : NurbsCurve
Transform a curve with the given matrix.
params
- 4d array representing the transform
returns
- A point represented as an array
transformAsync
METHOD
transformAsync(mat : Matrix) : Promise<NurbsCurve>
The async version of transform
point
METHOD
point(u : Float) : Point
Sample a point at the given parameter
params
- The parameter to sample the curve
returns
- A point represented as an array
pointAsync
METHOD
pointAsync(u : Float) : Promise<Point>
The async version of point
tangent
METHOD
tangent(u : Float) : Vector
Obtain the curve tangent at the given parameter. This is the first derivative and is not normalized
params
- The parameter to sample the curve
returns
- A point represented as an array
tangentAsync
METHOD
tangentAsync(u : Float) : Promise<Vector>
The async version of tangent
derivatives
METHOD
derivatives(u : Float, numDerivs : Int) : Array<Vector>
Get derivatives at a given parameter
params
- The parameter to sample the curve
- The number of derivatives to obtain
returns
- A point represented as an array
derivativesAsync
METHOD
derivativesAsync(u : Float, numDerivs : Int) : Promise<Array<Vector>>
The async version of derivatives
closestPoint
METHOD
closestPoint(pt : Point) : Point
Determine the closest point on the curve to the given point
params
- A length 3 array representing the point
returns
- The closest point
closestPointAsync
METHOD
closestPointAsync(pt : Point) : Promise<Point>
The async version of closestPoint
closestParam
METHOD
closestParam(pt : Point) : Float
Determine the closest parameter on the curve to the given point
params
- A length 3 array representing the point
returns
- The closest parameter
closestParamAsync
METHOD
closestParamAsync(pt : Dynamic) : Promise<Point>
The async version of length
length
METHOD
length() : Float
Determine the arc length of the curve
returns
- The length of the curve
lengthAsync
METHOD
lengthAsync() : Promise<Float>
The async version of length
lengthAtParam
METHOD
lengthAtParam(u : Float) : Float
Determine the arc length of the curve at the given parameter
params
- The parameter at which to evaluate
returns
- The length of the curve at the given parameter
lengthAtParamAsync
METHOD
lengthAtParamAsync() : Promise<Float>
The async version of lengthAtParam
paramAtLength
METHOD
paramAtLength(len : Float, tolerance : Float) : Float
Determine the parameter of the curve at the given arc length
params
- The arc length at which to determine the parameter
returns
- The length of the curve at the given parameter
paramAtLengthAsync
METHOD
paramAtLengthAsync(len : Float, tolerance : Float) : Promise<Float>
The async version of paramAtLength
divideByEqualArcLength
METHOD
divideByEqualArcLength(divisions : Int) : Array<CurveLengthSample>
Determine the parameters necessary to divide the curve into equal arc length segments
params
- Number of divisions of the curve
returns
- A collection of parameters
divideByEqualArcLengthAsync
METHOD
divideByEqualArcLengthAsync(divisions : Int) : Promise<Array<CurveLengthSample>>
The async version of `divideByEqualArcLength``
divideByArcLength
METHOD
divideByArcLength(arcLength : Float) : Array<CurveLengthSample>
Given the distance to divide the curve, determine the parameters necessary to divide the curve into equal arc length segments
params
- Arc length of each segment
returns
- A collection of parameters
divideByArcLengthAsync
METHOD
divideByArcLengthAsync(divisions : Int) : Promise<Array<CurveLengthSample>>
The async version of divideByArcLength
split
METHOD
split(u : Float) : Array<NurbsCurve>
Split the curve at the given parameter
params
- The parameter at which to split the curve
returns
- Two curves - one at the lower end of the parameter range and one at the higher end.
splitAsync
METHOD
splitAsync(u : Float) : Promise<Array<NurbsCurve>>
The async version of split
reverse
METHOD
reverse() : NurbsCurve
Reverse the parameterization of the curve
returns
- A reversed curve
reverseAsync
METHOD
reverseAsync() : Promise<NurbsCurve>
The async version of reverse
tessellate
METHOD
tessellate(tolerance : Float) : Array<Point>
Tessellate a curve at a given tolerance
params
- The tolerance at which to sample the curve
returns
- A point represented as an array
tessellateAsync
METHOD
tessellateAsync(tolerance : Float) : Promise<Array<Point>>
The async version of tessellate