A RationalQuadraticSpline2d
is a rational quadratic Bézier curve in 2D
defined by three control points and corresponding weights. This module contains
functionality for
Geometry.Types.RationalQuadraticSpline2d units coordinates
fromControlPoints : ( Point2d units coordinates, Basics.Float ) -> ( Point2d units coordinates, Basics.Float ) -> ( Point2d units coordinates, Basics.Float ) -> RationalQuadraticSpline2d units coordinates
Construct a spline from its four control points and associated weights.
exampleSpline =
RationalQuadraticSpline2d.fromControlPoints
( Point2d.meters 1 1, 1 )
( Point2d.meters 3 4, 2 )
( Point2d.meters 5 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.
bSplineSegments : List Basics.Float -> List ( Point2d units coordinates, Basics.Float ) -> List (RationalQuadraticSpline2d 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.
startPoint : RationalQuadraticSpline2d units coordinates -> Point2d units coordinates
Get the start point of a spline. Equal to
firstControlPoint
.
endPoint : RationalQuadraticSpline2d units coordinates -> Point2d units coordinates
Get the end point of a spline. Equal to
thirdControlPoint
.
startDerivative : RationalQuadraticSpline2d units coordinates -> Vector2d units coordinates
Get the start derivative of a spline;
RationalQuadraticSpline2d.startDerivative spline
is equivalent to (but more efficient than)
RationalQuadraticSpline2d.firstDerivative spline 0
endDerivative : RationalQuadraticSpline2d units coordinates -> Vector2d units coordinates
Get the end derivative of a spline;
RationalQuadraticSpline2d.endDerivative spline
is equivalent to (but more efficient than)
RationalQuadraticSpline2d.firstDerivative spline 1
boundingBox : RationalQuadraticSpline2d units coordinates -> BoundingBox2d 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).
RationalQuadraticSpline2d.boundingBox exampleSpline
--> BoundingBox2d.from
--> (Point2d.meters 1 1)
--> (Point2d.meters 5 4)
firstControlPoint : RationalQuadraticSpline2d units coordinates -> Point2d units coordinates
Get the first control point of the spline. Equal to
startPoint
.
secondControlPoint : RationalQuadraticSpline2d units coordinates -> Point2d units coordinates
Get the second control point of the spline.
thirdControlPoint : RationalQuadraticSpline2d units coordinates -> Point2d units coordinates
Get the third and last control point of the spline. Equal to endPoint
.
firstWeight : RationalQuadraticSpline2d units coordinates -> Basics.Float
Get the weight corresponding to the first control point of the spline.
secondWeight : RationalQuadraticSpline2d units coordinates -> Basics.Float
Get the weight corresponding to the second control point of the spline.
thirdWeight : RationalQuadraticSpline2d units coordinates -> Basics.Float
Get the weight corresponding to the third control point of the spline.
pointOn : RationalQuadraticSpline2d units coordinates -> Basics.Float -> Point2d units coordinates
Get the point along a spline at a given parameter value.
segments : Basics.Int -> RationalQuadraticSpline2d units coordinates -> Polyline2d 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 -> RationalQuadraticSpline2d units coordinates -> Polyline2d 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 Point2d
module.
reverse : RationalQuadraticSpline2d units coordinates -> RationalQuadraticSpline2d units coordinates
Reverse a spline so that the start point becomes the end point, and vice versa.
scaleAbout : Point2d units coordinates -> Basics.Float -> RationalQuadraticSpline2d units coordinates -> RationalQuadraticSpline2d units coordinates
Scale a spline about the given center point by the given scale.
rotateAround : Point2d units coordinates -> Angle -> RationalQuadraticSpline2d units coordinates -> RationalQuadraticSpline2d units coordinates
Rotate a spline counterclockwise around a given center point by a given angle.
translateBy : Vector2d units coordinates -> RationalQuadraticSpline2d units coordinates -> RationalQuadraticSpline2d units coordinates
Translate a spline by a given displacement.
translateIn : Direction2d coordinates -> Quantity Basics.Float units -> RationalQuadraticSpline2d units coordinates -> RationalQuadraticSpline2d units coordinates
Translate a spline in a given direction by a given distance.
mirrorAcross : Axis2d units coordinates -> RationalQuadraticSpline2d units coordinates -> RationalQuadraticSpline2d units coordinates
Mirror a spline across an axis.
at : Quantity Basics.Float (Quantity.Rate units2 units1) -> RationalQuadraticSpline2d units1 coordinates -> RationalQuadraticSpline2d 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) -> RationalQuadraticSpline2d units1 coordinates -> RationalQuadraticSpline2d 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 : Frame2d units globalCoordinates { defines : localCoordinates } -> RationalQuadraticSpline2d units globalCoordinates -> RationalQuadraticSpline2d units localCoordinates
Take a spline defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
placeIn : Frame2d units globalCoordinates { defines : localCoordinates } -> RationalQuadraticSpline2d units localCoordinates -> RationalQuadraticSpline2d 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 : RationalQuadraticSpline2d units coordinates -> ( RationalQuadraticSpline2d units coordinates, RationalQuadraticSpline2d units coordinates )
Split a spline into two roughly equal halves. Equivalent to
RationalQuadraticSpline2d.splitAt 0.5
.
splitAt : Basics.Float -> RationalQuadraticSpline2d units coordinates -> ( RationalQuadraticSpline2d units coordinates, RationalQuadraticSpline2d 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 -> RationalQuadraticSpline2d units coordinates -> Basics.Int
Determine the number of linear segments needed to approximate a quadratic spline to within a given tolerance.
firstDerivative : RationalQuadraticSpline2d units coordinates -> Basics.Float -> Vector2d units coordinates
Get the first derivative of a spline at a given parameter value.
secondDerivative : RationalQuadraticSpline2d units coordinates -> Basics.Float -> Vector2d units coordinates
Evaluate the second derivative of a spline at a given parameter value.
firstDerivativeBoundingBox : RationalQuadraticSpline2d units coordinates -> VectorBoundingBox2d units coordinates
Get the bounds on the first derivative of a spline.
secondDerivativeBoundingBox : RationalQuadraticSpline2d units coordinates -> VectorBoundingBox2d units coordinates
Compute the bounds on the second derivative of a spline.