opensolid/geometry/1.2.0

NOTE: this package is not compatible with Elm 0.19.1

OpenSolid.QuadraticSpline3d

QuadraticSpline3d

A QuadraticSpline3d is a quadratic Bézier curve in 3D defined by three control points. This module contains functionality for

  • Evaluating points and derivatives along a spline
  • Scaling, rotating, translating or mirroring a spline
  • Converting a spline between local and global coordinates in different reference frames

Splines can be constructed by passing a tuple of control points to the QuadraticSpline3d constructor, for example

exampleSpline =
    QuadraticSpline3d
        ( Point3d ( 1, 1, 1 )
        , Point3d ( 3, 2, 1 )
        , Point3d ( 3, 3, 3 )
        )

Constructors

bezier : Point3d -> Point3d -> Point3d -> QuadraticSpline3d

Construct a spline from its three control points. This is the same as just using the QuadraticSpline3d constructor directly;

QuadraticSpline3d.bezier p1 p2 p3

is equivalent to

QuadraticSpline3d ( p1, p2, p3 )

Accessors

controlPoints : QuadraticSpline3d -> ( Point3d, Point3d, Point3d )

Get the control points of a spline as a tuple.

( p1, p2, p3 ) =
    QuadraticSpline3d.controlPoints exampleSpline




--> p1 = Point3d ( 1, 1, 1 )
--> p2 = Point3d ( 3, 2, 1 )
--> p3 = Point3d ( 3, 3, 3 )
startPoint : QuadraticSpline3d -> Point3d

Get the start point of a spline. This is equal to the spline's first control point.

QuadraticSpline3d.startPoint exampleSpline
--> Point3d ( 1, 1, 1 )
endPoint : QuadraticSpline3d -> Point3d

Get the end point of a spline. This is equal to the spline's last control point.

QuadraticSpline3d.endPoint exampleSpline
--> Point3d ( 3, 3, 3 )
startDerivative : QuadraticSpline3d -> Vector3d

Get the start derivative of a spline. This is equal to twice the vector from the spline's first control point to its second.

QuadraticSpline3d.startDerivative exampleSpline
--> Vector3d ( 4, 2, 0 )
endDerivative : QuadraticSpline3d -> Vector3d

Get the end derivative of a spline. This is equal to twice the vector from the spline's second control point to its third.

QuadraticSpline3d.endDerivative exampleSpline
--> Vector3d ( 0, 2, 4 )

Evaluation

point : QuadraticSpline3d -> Float -> Point3d

Get a point along a spline, based on a parameter that ranges from 0 to 1. A parameter value of 0 corresponds to the start point of the spline and a value of 1 corresponds to the end point.

QuadraticSpline3d.point exampleSpline 0
--> Point3d ( 1, 1, 1 )


QuadraticSpline3d.point exampleSpline 0.5
--> Point3d ( 2.5, 2, 1.5 )


QuadraticSpline3d.point exampleSpline 1
--> Point3d ( 3, 3, 3 )
derivative : QuadraticSpline3d -> Float -> Vector3d

Get the deriative value at a point along a spline, based on a parameter that ranges from 0 to 1. A parameter value of 0 corresponds to the start derivative of the spline and a value of 1 corresponds to the end derivative.

QuadraticSpline3d.derivative exampleSpline 0
--> Vector3d ( 4, 2, 0 )


QuadraticSpline3d.derivative exampleSpline 0.5
--> Vector3d ( 2, 2, 2 )


QuadraticSpline3d.derivative exampleSpline 1
--> Vector3d ( 0, 2, 4 )

Note that the derivative interpolates linearly from end to end.

Transformations

scaleAbout : Point3d -> Float -> QuadraticSpline3d -> QuadraticSpline3d

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

QuadraticSpline3d.scaleAbout Point3d.origin 2 exampleSpline
--> QuadraticSpline3d
-->     ( Point3d ( 2, 2, 2 )
-->     , Point3d ( 6, 4, 2 )
-->     , Point3d ( 6, 6, 6 )
-->     )
rotateAround : Axis3d -> Float -> QuadraticSpline3d -> QuadraticSpline3d

Rotate a spline counterclockwise around a given axis by a given angle (in radians).

QuadraticSpline3d.rotateAround Axis3d.z (degrees 90) exampleSpline
--> QuadraticSpline3d
-->     ( Point3d ( -1, 1, 1 )
-->     , Point3d ( -2, 3, 1 )
-->     , Point3d ( -3, 3, 3 )
-->     )
translateBy : Vector3d -> QuadraticSpline3d -> QuadraticSpline3d

Translate a spline by a given displacement.

displacement =
    Vector3d ( 2, 3, 1 )


QuadraticSpline3d.translateBy displacement exampleSpline
--> QuadraticSpline3d
-->     ( Point3d ( 3, 4, 2 )
-->     , Point3d ( 5, 5, 2 )
-->     , Point3d ( 5, 6, 4 )
-->     )
mirrorAcross : Plane3d -> QuadraticSpline3d -> QuadraticSpline3d

Mirror a spline across a plane.

QuadraticSpline3d.mirrorAcross Plane3d.xy exampleSpline
--> QuadraticSpline3d
-->     ( Point3d ( 1, 1, -1 )
-->     , Point3d ( 3, 2, -1 )
-->     , Point3d ( 3, 3, -3 )
-->     )
projectOnto : Plane3d -> QuadraticSpline3d -> QuadraticSpline3d

Project a spline onto a plane.

QuadraticSpline3d.projectOnto Plane3d.xy exampleSpline
--> QuadraticSpline3d
-->     ( Point3d ( 1, 1, 0 )
-->     , Point3d ( 3, 2, 0 )
-->     , Point3d ( 3, 3, 0 )
-->     )

Coordinate frames

relativeTo : Frame3d -> QuadraticSpline3d -> QuadraticSpline3d

Take a spline defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.

localFrame =
    Frame3d.at (Point3d ( 1, 2, 3 ))


QuadraticSpline3d.relativeTo localFrame exampleSpline
--> QuadraticSpline3d
-->     ( Point3d ( 0, -1, -2 )
-->     , Point3d ( 2, 0, -2 )
-->     , Point3d ( 2, 1, 0 )
-->     )
placeIn : Frame3d -> QuadraticSpline3d -> QuadraticSpline3d

Take a spline considered to be defined in local coordinates relative to a given reference frame, and return that spline expressed in global coordinates.

localFrame =
    Frame3d.at (Point3d ( 1, 2, 3 ))


QuadraticSpline3d.placeIn localFrame exampleSpline
--> QuadraticSpline3d
-->     ( Point3d ( 2, 3, 4 )
-->     , Point3d ( 4, 4, 4 )
-->     , Point3d ( 4, 5, 6 )
-->     )

Sketch planes

projectInto : SketchPlane3d -> QuadraticSpline3d -> QuadraticSpline2d

Project a spline into a given sketch plane. Conceptually, this projects the spline onto the plane and then expresses the projected spline in 2D sketch coordinates.

QuadraticSpline3d.projectInto SketchPlane3d.yz exampleSpline
--> QuadraticSpline2d
-->     ( Point2d ( 1, 1 )
-->     , Point2d ( 2, 1 )
-->     , Point2d ( 3, 3 )
-->     )