ianmackenzie / elm-geometry / Arc3d

An Arc3d is a section of a circle in 3D, defined by its central axis, start point and swept angle (the counterclockwise angle around the axis from the start point to the arc's end point). This module includes functionality for


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

Constructors

on : SketchPlane3d units coordinates3d { defines : coordinates2d } -> Arc2d units coordinates2d -> Arc3d units coordinates3d

Construct a 3D arc lying on a sketch plane by providing a 2D arc specified in XY coordinates within the sketch plane.

arc =
    Arc3d.on SketchPlane3d.xz
        (Point2d.meters 3 1
            |> Arc2d.sweptAround (Point2d.meters 1 1)
                (Angle.degrees 90)
        )

Arc3d.startPoint arc
--> Point3d.meters 3 0 1

Arc3d.endPoint arc
--> Point3d.meters 1 0 3

sweptAround : Axis3d units coordinates -> Angle -> Point3d units coordinates -> Arc3d units coordinates

Construct an arc by sweeping the given point around the given axis by the given angle:

exampleArc =
    Point3d.meters 1 1 0
        |> Arc3d.sweptAround Axis3d.z
            (Angle.degrees 90)

Arc3d.endPoint exampleArc
--> Point3d.meters -1 1 0

Positive swept angles result in a counterclockwise (right-handed) rotation around the given axis and vice versa for negative swept angles. The center point of the returned arc will lie on the given axis.

throughPoints : Point3d units coordinates -> Point3d units coordinates -> Point3d units coordinates -> Maybe (Arc3d units coordinates)

Attempt to construct an arc that starts at the first given point, passes through the second given point and ends at the third given point. If the three points are collinear, returns Nothing.

Arc3d.throughPoints
    (Point3d.meters 0 0 1)
    Point3d.origin
    (Point3d.meters 0 1 0)
--> Just <|
-->     Arc3d.on SketchPlane3d.yz
-->         (Point2d.meters 0 1
-->             |> Arc2d.sweptAround
-->                 (Point2d.meters 0.5 0.5)
-->                 (Angle.degrees 180)
-->         )

Properties

axialDirection : Arc3d units coordinates -> Direction3d coordinates

Get the axial direction of an arc.

Arc3d.axialDirection exampleArc
--> Direction3d.z

axis : Arc3d units coordinates -> Axis3d units coordinates

Get the central axis of an arc. The origin point of the axis will be equal to the center point of the arc.

centerPoint : Arc3d units coordinates -> Point3d units coordinates

Get the center point of an arc.

radius : Arc3d units coordinates -> Quantity Basics.Float units

Get the radius of an arc.

startPoint : Arc3d units coordinates -> Point3d units coordinates

Get the start point of an arc.

midpoint : Arc3d units coordinates -> Point3d units coordinates

Get the midpoint of an arc.

endPoint : Arc3d units coordinates -> Point3d units coordinates

Get the end point of an arc.

sweptAngle : Arc3d units coordinates -> Angle

Get the swept angle of an arc. A positive swept angle means that the arc is formed by rotating the given start point counterclockwise around the central axis, and vice versa for a negative angle.

boundingBox : Arc3d units coordinates -> BoundingBox3d units coordinates

Get a bounding box for a given arc.

Evaluation

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

Get the point along an arc at a given parameter value.


type Nondegenerate units coordinates

Represents a nondegenerate spline (one that has finite, non-zero length).

nondegenerate : Arc3d units coordinates -> Result (Point3d units coordinates) (Nondegenerate units coordinates)

Attempt to construct a nondegenerate arc from a general Arc3d. If the arc is in fact degenerate (consists of a single point), returns an Err with that point.

fromNondegenerate : Nondegenerate units coordinates -> Arc3d units coordinates

Convert a nondegenerate arc back to a general Arc3d.

tangentDirection : Nondegenerate units coordinates -> Basics.Float -> Direction3d coordinates

Get the tangent direction to a nondegenerate arc at a given parameter value.

sample : Nondegenerate units coordinates -> Basics.Float -> ( Point3d units coordinates, Direction3d coordinates )

Get both the point and tangent direction of a nondegenerate arc at a given parameter value.

Linear approximation

segments : Basics.Int -> Arc3d units coordinates -> Polyline3d units coordinates

Approximate an arc by a given number of line segments:

Arc3d.segments 3 exampleArc
--> Polyline3d.fromVertices
-->     [ Point3d.meters 1 1 0
-->     , Point3d.meters 1 1.4142 0
-->     , Point3d.meters -1 1 0
-->     ]

approximate : Quantity Basics.Float units -> Arc3d units coordinates -> Polyline3d units coordinates

Approximate an arc as a polyline, within a given tolerance:

Arc3d.approximate (Length.meters 0.1) exampleArc
--> Polyline3d.fromVertices
-->     [ Point3d.meters 1 1 0
-->     , Point3d.meters 0.366 1.366 0
-->     , Point3d.meters -0.366 1.366 0
-->     , Point3d.meters -1 1 0
-->     ]

In this example, every point on the returned polyline will be within 0.1 meters of the original arc.

toPolyline : { maxError : Quantity Basics.Float units } -> Arc3d units coordinates -> Polyline3d units coordinates

DEPRECATED - use segments or approximate instead.

Transformations

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

reverse : Arc3d units coordinates -> Arc3d units coordinates

Reverse the direction of an arc, so that the start point becomes the end point and vice versa. The resulting arc will have the same axis as the original but a swept angle with the opposite sign.

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

Scale an arc about the given center point by the given scale.

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

Rotate an arc around a given axis by a given angle.

translateBy : Vector3d units coordinates -> Arc3d units coordinates -> Arc3d units coordinates

Translate an arc by a given displacement.

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

Translate an arc in a given direction by a given distance.

mirrorAcross : Plane3d units coordinates -> Arc3d units coordinates -> Arc3d units coordinates

Mirror an arc across a given plane. This flips the sign of the arc's swept angle.

projectOnto : Plane3d units coordinates -> Arc3d units coordinates -> EllipticalEllipticalArc3d units coordinates

Project an arc onto a plane. Note that the result is an elliptical arc, not a circular one!

projectInto : SketchPlane3d units coordinates3d { defines : coordinates2d } -> Arc3d units coordinates3d -> EllipticalArc2d units coordinates2d

Project an arc into a sketch plane. Note that the result is an elliptical arc, not a circular one!

Unit conversions

at : Quantity Basics.Float (Quantity.Rate units2 units1) -> Arc3d units1 coordinates -> Arc3d units2 coordinates

Convert an arc 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) -> Arc3d units1 coordinates -> Arc3d units2 coordinates

Convert an arc 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 } -> Arc3d units globalCoordinates -> Arc3d units localCoordinates

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

placeIn : Frame3d units globalCoordinates { defines : localCoordinates } -> Arc3d units localCoordinates -> Arc3d units globalCoordinates

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

Advanced

You are unlikely to need to use these functions directly, but they are useful if you are writing low-level geometric algorithms.

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

Get the first derivative of an arc at a given parameter value.

firstDerivativeBoundingBox : Arc3d units coordinates -> VectorBoundingBox3d units coordinates

Get the bounds on the first derivative of an arc.

numApproximationSegments : Quantity Basics.Float units -> Arc3d units coordinates -> Basics.Int

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