ianmackenzie / elm-geometry / RationalQuadraticSpline3d

A RationalQuadraticSpline3d is a rational quadratic Bézier curve in 3D defined by three control points and corresponding weights. This module contains functionality for


type alias RationalQuadraticSpline3d units coordinates =
Geometry.Types.RationalQuadraticSpline3d units coordinates

Constructors

fromControlPoints : ( Point3d units coordinates, Basics.Float ) -> ( Point3d units coordinates, Basics.Float ) -> ( Point3d units coordinates, Basics.Float ) -> RationalQuadraticSpline3d units coordinates

Construct a spline from its four control points and associated weights.

exampleSpline =
    RationalQuadraticSpline3d.fromControlPoints
        ( Point3d.meters 1 0 1, 1 )
        ( Point3d.meters 3 0 4, 2 )
        ( Point3d.meters 5 0 1, 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.

B-splines

bSplineSegments : List Basics.Float -> List ( Point3d units coordinates, Basics.Float ) -> List (RationalQuadraticSpline3d 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 one 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 two times; for example, the knots

[ 0, 0, 1, 2, 3, 4, 4 ]

could be used along with 6 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 three greater than the number of control points (especially if you also notice that the first and last knots are repeated three times instead of two!) 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.

Properties

startPoint : RationalQuadraticSpline3d units coordinates -> Point3d units coordinates

Get the start point of a spline. Equal to firstControlPoint.

endPoint : RationalQuadraticSpline3d units coordinates -> Point3d units coordinates

Get the end point of a spline. Equal to thirdControlPoint.

startDerivative : RationalQuadraticSpline3d units coordinates -> Vector3d units coordinates

Get the start derivative of a spline;

RationalQuadraticSpline3d.startDerivative spline

is equivalent to (but more efficient than)

RationalQuadraticSpline3d.firstDerivative spline 0

endDerivative : RationalQuadraticSpline3d units coordinates -> Vector3d units coordinates

Get the end derivative of a spline;

RationalQuadraticSpline3d.endDerivative spline

is equivalent to (but more efficient than)

RationalQuadraticSpline3d.firstDerivative spline 1

boundingBox : RationalQuadraticSpline3d 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).

RationalQuadraticSpline3d.boundingBox exampleSpline
--> BoundingBox3d.from
-->     (Point3d.meters 1 0 1)
-->     (Point3d.meters 5 0 4)

Control points and weights

firstControlPoint : RationalQuadraticSpline3d units coordinates -> Point3d units coordinates

Get the first control point of the spline. Equal to startPoint.

secondControlPoint : RationalQuadraticSpline3d units coordinates -> Point3d units coordinates

Get the second control point of the spline.

thirdControlPoint : RationalQuadraticSpline3d units coordinates -> Point3d units coordinates

Get the third and last control point of the spline. Equal to endPoint.

firstWeight : RationalQuadraticSpline3d units coordinates -> Basics.Float

Get the weight corresponding to the first control point of the spline.

secondWeight : RationalQuadraticSpline3d units coordinates -> Basics.Float

Get the weight corresponding to the second control point of the spline.

thirdWeight : RationalQuadraticSpline3d units coordinates -> Basics.Float

Get the weight corresponding to the third control point of the spline.

Evaluation

pointOn : RationalQuadraticSpline3d units coordinates -> Basics.Float -> Point3d units coordinates

Get the point along a spline at a given parameter value.

Linear approximation

segments : Basics.Int -> RationalQuadraticSpline3d 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 -> RationalQuadraticSpline3d 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.

Transformations

These transformations generally behave just like the ones in the Point3d module.

reverse : RationalQuadraticSpline3d units coordinates -> RationalQuadraticSpline3d units coordinates

Reverse a spline so that the start point becomes the end point, and vice versa.

scaleAbout : Point3d units coordinates -> Basics.Float -> RationalQuadraticSpline3d units coordinates -> RationalQuadraticSpline3d units coordinates

Scale a spline about the given center point by the given scale.

rotateAround : Axis3d units coordinates -> Angle -> RationalQuadraticSpline3d units coordinates -> RationalQuadraticSpline3d units coordinates

Rotate a spline counterclockwise around a given center point by a given angle.

translateBy : Vector3d units coordinates -> RationalQuadraticSpline3d units coordinates -> RationalQuadraticSpline3d units coordinates

Translate a spline by a given displacement.

translateIn : Direction3d coordinates -> Quantity Basics.Float units -> RationalQuadraticSpline3d units coordinates -> RationalQuadraticSpline3d units coordinates

Translate a spline in a given direction by a given distance.

mirrorAcross : Geometry.Types.Plane3d units coordinates -> RationalQuadraticSpline3d units coordinates -> RationalQuadraticSpline3d units coordinates

Mirror a spline across an axis.

Unit conversions

at : Quantity Basics.Float (Quantity.Rate units2 units1) -> RationalQuadraticSpline3d units1 coordinates -> RationalQuadraticSpline3d 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) -> RationalQuadraticSpline3d units1 coordinates -> RationalQuadraticSpline3d 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.

Coordinate conversions

relativeTo : Frame3d units globalCoordinates { defines : localCoordinates } -> RationalQuadraticSpline3d units globalCoordinates -> RationalQuadraticSpline3d 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 } -> RationalQuadraticSpline3d units localCoordinates -> RationalQuadraticSpline3d 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.

Subdivision

bisect : RationalQuadraticSpline3d units coordinates -> ( RationalQuadraticSpline3d units coordinates, RationalQuadraticSpline3d units coordinates )

Split a spline into two roughly equal halves. Equivalent to RationalQuadraticSpline3d.splitAt 0.5.

splitAt : Basics.Float -> RationalQuadraticSpline3d units coordinates -> ( RationalQuadraticSpline3d units coordinates, RationalQuadraticSpline3d units coordinates )

Split a spline at a particular parameter value, resulting in two smaller splines.

Advanced

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 -> RationalQuadraticSpline3d units coordinates -> Basics.Int

Determine the number of linear segments needed to approximate a spline to within a given tolerance.

firstDerivative : RationalQuadraticSpline3d units coordinates -> Basics.Float -> Vector3d units coordinates

Get the first derivative of a spline at a given parameter value.

secondDerivative : RationalQuadraticSpline3d units coordinates -> Basics.Float -> Vector3d units coordinates

Evaluate the second derivative of a spline at a given parameter value.

firstDerivativeBoundingBox : RationalQuadraticSpline3d units coordinates -> VectorBoundingBox3d units coordinates

Get the bounds on the first derivative of a spline.

secondDerivativeBoundingBox : RationalQuadraticSpline3d units coordinates -> VectorBoundingBox3d units coordinates

Compute the bounds on the second derivative of a spline.

maxSecondDerivativeMagnitude : RationalQuadraticSpline3d units coordinates -> Quantity Basics.Float units

Find the maximum magnitude of the second derivative of a spline.