A Spline3d
is a Bézier curve
in 3D defined by a list of control points. This module contains functionality
for
In general you will want to use a QuadraticSpline3d
or
CubicSpline3d
instead, but a Spline3d
can be useful if you
need to support arbitrary spline degrees (for example quartic or quintic
splines) or if the spline degree is not known at compile time.
Geometry.Types.Spline3d units coordinates
fromControlPoints : Point3d units coordinates -> List (Point3d units coordinates) -> Spline3d units coordinates
Construct a spline from its control points. In order to guarantee that a spline has at least one control point, you must pass the first and remaining control points separately.
fromQuadraticSpline : QuadraticQuadraticSpline3d units coordinates -> Spline3d units coordinates
Convert a QuadraticSpline3d
to a generic Spline3d
.
fromCubicSpline : CubicCubicSpline3d units coordinates -> Spline3d units coordinates
Convert a CubicSpline3d
to a generic Spline3d
.
on : SketchPlane3d units coordinates3d { defines : coordinates2d } -> Spline2d units coordinates2d -> Spline3d units coordinates3d
Project a spline into a given sketch plane.
bSplineSegments : Basics.Int -> List Basics.Float -> List (Point3d units coordinates) -> List (Spline3d units coordinates)
Construct a B-spline from a given polynomial degree (2 for a quadratic spline, 3 for a cubic spline etc.), 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 equal to the number of control points plus the
given degree, minus 1; for example, for a cubic spline (degree 3) the number of
knots should be 2 greater than the number of control points. A popular alternate
convention uses two extra 'dummy' knot values at the start and end, so the
number of knots is equal to the given degree plus one. The bSplineSegments
function supports both conventions - if the number of knots is equal to the
degree plus one then the first and last knots will be dropped.
In most cases the first and last knots will be repeated a number of times equal to the spline degree (or the degree plus one, for the alternate convention described above); for example for a quadratic spline the first and last knots will be repeated twice and for a cubic spline they will be repeated three times.
Knot values should be given in ascending order but will be sorted if necessary. If the number of knots does not follow either of the conventions described above, an empty list will be returned.
bSplineIntervals : Basics.Int -> List Basics.Float -> List (Interval Basics.Float)
For a given degree and set of B-spline knots, return the corresponding intervals between knots that correspond to individual spline segments.
controlPoints : Spline3d units coordinates -> List (Point3d units coordinates)
Get the control points of a spline as a list.
degree : Spline3d units coordinates -> Basics.Int
Get the polynomial degree of a spline; this is equal to the number of control points minus one. A single point has degree 0, a line segment has degree 1, a quadratic spline has degree 2, a cubic spline has degree 3, etc.
startPoint : Spline3d units coordinates -> Point3d units coordinates
Get the start point of a spline.
endPoint : Spline3d units coordinates -> Point3d units coordinates
Get the end point of a spline.
startDerivative : Spline3d units coordinates -> Vector3d units coordinates
Get the start derivative of a spline.
endDerivative : Spline3d units coordinates -> Vector3d units coordinates
Get the end derivative of a spline.
boundingBox : Spline3d 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 volume than the spline itself).
pointOn : Spline3d units coordinates -> Basics.Float -> Point3d units coordinates
Get a point on a spline at a given parameter value.
segments : Basics.Int -> Spline3d 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 -> Spline3d 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 : Spline3d units coordinates -> Spline3d units coordinates
Reverse a spline so that the start point becomes the end point, and vice versa.
scaleAbout : Point3d units coordinates -> Basics.Float -> Spline3d units coordinates -> Spline3d units coordinates
Scale a spline about the given center point by the given scale.
rotateAround : Axis3d units coordinates -> Angle -> Spline3d units coordinates -> Spline3d units coordinates
Rotate a spline counterclockwise around a given axis by a given angle.
translateBy : Vector3d units coordinates -> Spline3d units coordinates -> Spline3d units coordinates
Translate a spline by a given displacement.
translateIn : Direction3d coordinates -> Quantity Basics.Float units -> Spline3d units coordinates -> Spline3d units coordinates
Translate a spline in a given direction by a given distance.
mirrorAcross : Plane3d units coordinates -> Spline3d units coordinates -> Spline3d units coordinates
Mirror a spline across a plane.
projectOnto : Plane3d units coordinates -> Spline3d units coordinates -> Spline3d units coordinates
Find the orthographic projection of a spline onto a plane.
at : Quantity Basics.Float (Quantity.Rate units2 units1) -> Spline3d units1 coordinates -> Spline3d 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) -> Spline3d units1 coordinates -> Spline3d 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 } -> Spline3d units globalCoordinates -> Spline3d 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 } -> Spline3d units localCoordinates -> Spline3d 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.
projectInto : SketchPlane3d units coordinates3d { defines : coordinates2d } -> Spline3d units coordinates3d -> Spline2d units coordinates2d
Project a spline into a given sketch plane.
bisect : Spline3d units coordinates -> ( Spline3d units coordinates, Spline3d units coordinates )
Split a spline into two roughly equal halves. Equivalent to
Spline3d.splitAt 0.5
.
splitAt : Basics.Float -> Spline3d units coordinates -> ( Spline3d units coordinates, Spline3d 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.
firstDerivative : Spline3d units coordinates -> Basics.Float -> Vector3d units coordinates
Get the first derivative of a spline at a given parameter value.
secondDerivative : Spline3d units coordinates -> Basics.Float -> Vector3d units coordinates
Get the second derivative value at a point along a spline.
firstDerivativeBoundingBox : Spline3d units coordinates -> VectorBoundingBox3d units coordinates
Get the bounds on the first derivative of a spline.
secondDerivativeBoundingBox : Spline3d units coordinates -> VectorBoundingBox3d units coordinates
Get the bounds on the first derivative of a spline.
maxSecondDerivativeMagnitude : Spline3d units coordinates -> Quantity Basics.Float units
Find a conservative upper bound on the magnitude of the second derivative of a spline. This can be useful when determining error bounds for various kinds of linear approximations.
numApproximationSegments : Quantity Basics.Float units -> Spline3d units coordinates -> Basics.Int
Determine the number of linear segments needed to approximate a spline to within a given tolerance.