A RationalCubicSpline3d
is a rational cubic Bézier curve in 3D defined by
four control points and corresponding weights. This module contains
functionality for
Geometry.Types.RationalCubicSpline3d units coordinates
fromControlPoints : ( Point3d units coordinates, Basics.Float ) -> ( Point3d units coordinates, Basics.Float ) -> ( Point3d units coordinates, Basics.Float ) -> ( Point3d units coordinates, Basics.Float ) -> RationalCubicSpline3d units coordinates
Construct a spline from its four control points and associated weights.
exampleSpline =
RationalCubicSpline3d.fromControlPoints
( Point3d.meters 1 0 1, 1 )
( Point3d.meters 3 0 4, 2 )
( Point3d.meters 5 0 1, 2 )
( Point3d.meters 7 0 4, 1 )
All weights should be greater than zero. If any negative weights are passed, their absolute values will be used. Larger weights will tend to 'pull' the curve towards the corresponding control point.
bSplineSegments : List Basics.Float -> List ( Point3d units coordinates, Basics.Float ) -> List (RationalCubicSpline3d units coordinates)
Construct a non-uniform rational B-spline (also known as a NURBS curve) from a list of knot values and a list of control points, and return the individual segments of that B-spline as a list.
The number of knots should be two greater than the number of control points; any extra knots or control points will be dropped. In most cases the first and last knots will be repeated three times; for example, the knots
[ 0, 0, 0, 1, 2, 3, 4, 4, 4 ]
could be used along with 7 control points to form 4 spline segments.
Note that a popular alternate convention uses two extra 'dummy' knot values at the start and end, so if you see an example where the number of knots is four greater than the number of control points (especially if you also notice that the first and last knots are repeated four times instead of three!) then you should drop the first and last knot values.
Knot values should be given in ascending order but will be sorted if necessary.
bSplineIntervals : List Basics.Float -> List (Interval Basics.Float)
For a given set of B-spline knots, return the corresponding intervals between knots that correspond to individual spline segments.
startPoint : RationalCubicSpline3d units coordinates -> Point3d units coordinates
Get the start point of a spline. Equal to
firstControlPoint
.
endPoint : RationalCubicSpline3d units coordinates -> Point3d units coordinates
Get the end point of a spline. Equal to
fourthControlPoint
.
startDerivative : RationalCubicSpline3d units coordinates -> Vector3d units coordinates
Get the start derivative of a spline;
RationalCubicSpline3d.startDerivative spline
is equivalent to (but more efficient than)
RationalCubicSpline3d.firstDerivative spline 0
endDerivative : RationalCubicSpline3d units coordinates -> Vector3d units coordinates
Get the end derivative of a spline;
RationalCubicSpline3d.endDerivative spline
is equivalent to (but more efficient than)
RationalCubicSpline3d.firstDerivative spline 1
boundingBox : RationalCubicSpline3d units coordinates -> BoundingBox3d units coordinates
Compute a bounding box for a given spline. It is not guaranteed that the result will be the smallest possible bounding box, since for efficiency the bounding box is computed from the spline's control points (which cover a larger area than the spline itself).
RationalCubicSpline3d.boundingBox exampleSpline
--> BoundingBox3d.from
--> (Point3d.meters 1 0 1)
--> (Point3d.meters 7 0 4)
firstControlPoint : RationalCubicSpline3d units coordinates -> Point3d units coordinates
Get the first control point of the spline. Equal to
startPoint
.
secondControlPoint : RationalCubicSpline3d units coordinates -> Point3d units coordinates
Get the second control point of the spline.
thirdControlPoint : RationalCubicSpline3d units coordinates -> Point3d units coordinates
Get the third control point of the spline.
fourthControlPoint : RationalCubicSpline3d units coordinates -> Point3d units coordinates
Get the fourth and last control point of the spline.
Equal to endPoint
.
firstWeight : RationalCubicSpline3d units coordinates -> Basics.Float
Get the weight corresponding to the first control point of the spline.
secondWeight : RationalCubicSpline3d units coordinates -> Basics.Float
Get the weight corresponding to the second control point of the spline.
thirdWeight : RationalCubicSpline3d units coordinates -> Basics.Float
Get the weight corresponding to the third control point of the spline.
fourthWeight : RationalCubicSpline3d units coordinates -> Basics.Float
Get the weight corresponding to the fourth control point of the spline.
pointOn : RationalCubicSpline3d units coordinates -> Basics.Float -> Point3d units coordinates
Get the point along a spline at a given parameter value.
segments : Basics.Int -> RationalCubicSpline3d units coordinates -> Polyline3d units coordinates
Approximate a spline by a given number of line segments. Note that the number of points in the polyline will be one more than the number of segments.
approximate : Quantity Basics.Float units -> RationalCubicSpline3d units coordinates -> Polyline3d units coordinates
Approximate a spline as a polyline, within a given tolerance. Every point on the returned polyline will be within the given tolerance of the spline.
These transformations generally behave just like the ones in the Point3d
module.
reverse : RationalCubicSpline3d units coordinates -> RationalCubicSpline3d units coordinates
Reverse a spline so that the start point becomes the end point, and vice versa.
scaleAbout : Point3d units coordinates -> Basics.Float -> RationalCubicSpline3d units coordinates -> RationalCubicSpline3d units coordinates
Scale a spline about the given center point by the given scale.
rotateAround : Axis3d units coordinates -> Angle -> RationalCubicSpline3d units coordinates -> RationalCubicSpline3d units coordinates
Rotate a spline counterclockwise around a given center point by a given angle.
translateBy : Vector3d units coordinates -> RationalCubicSpline3d units coordinates -> RationalCubicSpline3d units coordinates
Translate a spline by a given displacement.
translateIn : Direction3d coordinates -> Quantity Basics.Float units -> RationalCubicSpline3d units coordinates -> RationalCubicSpline3d units coordinates
Translate a spline in a given direction by a given distance.
mirrorAcross : Geometry.Types.Plane3d units coordinates -> RationalCubicSpline3d units coordinates -> RationalCubicSpline3d units coordinates
Mirror a spline across an axis.
at : Quantity Basics.Float (Quantity.Rate units2 units1) -> RationalCubicSpline3d units1 coordinates -> RationalCubicSpline3d units2 coordinates
Convert a spline from one units type to another, by providing a conversion factor given as a rate of change of destination units with respect to source units.
at_ : Quantity Basics.Float (Quantity.Rate units1 units2) -> RationalCubicSpline3d units1 coordinates -> RationalCubicSpline3d units2 coordinates
Convert a spline from one units type to another, by providing an 'inverse' conversion factor given as a rate of change of source units with respect to destination units.
relativeTo : Frame3d units globalCoordinates { defines : localCoordinates } -> RationalCubicSpline3d units globalCoordinates -> RationalCubicSpline3d units localCoordinates
Take a spline defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
placeIn : Frame3d units globalCoordinates { defines : localCoordinates } -> RationalCubicSpline3d units localCoordinates -> RationalCubicSpline3d units globalCoordinates
Take a spline considered to be defined in local coordinates relative to a given reference frame, and return that spline expressed in global coordinates.
bisect : RationalCubicSpline3d units coordinates -> ( RationalCubicSpline3d units coordinates, RationalCubicSpline3d units coordinates )
Split a spline into two roughly equal halves. Equivalent to
RationalCubicSpline3d.splitAt 0.5
.
splitAt : Basics.Float -> RationalCubicSpline3d units coordinates -> ( RationalCubicSpline3d units coordinates, RationalCubicSpline3d units coordinates )
Split a spline at a particular parameter value, resulting in two smaller splines.
You are unlikely to need to use these functions directly, but they are useful if you are writing low-level geometric algorithms.
numApproximationSegments : Quantity Basics.Float units -> RationalCubicSpline3d units coordinates -> Basics.Int
Determine the number of linear segments needed to approximate a cubic spline to within a given tolerance.
firstDerivative : RationalCubicSpline3d units coordinates -> Basics.Float -> Vector3d units coordinates
Get the first derivative of a spline at a given parameter value.
secondDerivative : RationalCubicSpline3d units coordinates -> Basics.Float -> Vector3d units coordinates
Evaluate the second derivative of a spline at a given parameter value.
firstDerivativeBoundingBox : RationalCubicSpline3d units coordinates -> VectorBoundingBox3d units coordinates
Get the bounds on the first derivative of a spline.
secondDerivativeBoundingBox : RationalCubicSpline3d units coordinates -> VectorBoundingBox3d units coordinates
Compute the bounds on the second derivative of a spline.
maxSecondDerivativeMagnitude : RationalCubicSpline3d units coordinates -> Quantity Basics.Float units
Find the maximum magnitude of the second derivative of a spline.