opensolid/geometry/1.2.0

NOTE: this package is not compatible with Elm 0.19.1

OpenSolid.Arc3d

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

  • Constructing arcs through given points
  • Scaling, rotating, translating and mirroring arcs
  • Converting arcs between different coordinate systems

Arcs can be constructed explicitly by passing a record with axis, startPoint and sweptAngle fields to the Arc3d constructor, for example

exampleArc =
    Arc3d
        { axis = Axis3d.z
        , startPoint = Point3d ( 2, 0, 1 )
        , sweptAngle = degrees 90
        }

Note that the origin point of the axis is not required to be the same as the arc's center point - here the origin point of the given axis is Point3d.origin, while the center point of the arc is Point3d ( 0, 0, 1 ) (the start point of the arc projected onto the axis).

Constructors

throughPoints : Point3d -> Point3d -> Point3d -> Maybe Arc3d

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.

p1 =
    Point3d ( 0, 0, 1 )


p2 =
    Point3d.origin


p3 =
    Point3d ( 0, 1, 0 )


Arc3d.throughPoints p1 p2 p3
--> Just
-->     (Arc3d
-->         { axis =
-->             Axis3d
-->                 { originPoint = Point3d ( 0, 0.5, 0.5 )
-->                 , direction = Direction3d ( 1, 0, 0 )
-->                 }
-->         , startPoint = Point3d (0,0,1)
-->         , sweptAngle = 3.1416
-->         }
-->     )

Accessors

axis : Arc3d -> Axis3d

Get the central axis of an arc.

Arc3d.axis exampleArc
--> Axis3d.z
centerPoint : Arc3d -> Point3d

Get the center point of an arc.

Arc3d.centerPoint exampleArc
--> Point3d ( 0, 0, 1 )

The center point of an arc is equal to its start point projected onto its central axis, which may not be equal to the origin point of that axis.

axialDirection : Arc3d -> Direction3d

Get direction of an arc's axis;

Arc3d.axialDirection arc

is equivalent to

Axis3d.direction (Arc3d.axis arc)
radius : Arc3d -> Float

Get the radius of an arc.

Arc3d.radius exampleArc
--> 2
startPoint : Arc3d -> Point3d

Get the start point of an arc.

Arc3d.startPoint exampleArc
--> Point3d ( 2, 0, 1 )
endPoint : Arc3d -> Point3d

Get the end point of an arc.

Arc3d.endPoint exampleArc
--> Point3d ( 0, 2, 1 )
point : Arc3d -> Float -> Point3d

Get the point along an arc at a given parameter value. A parameter value of 0 corresponds to the start point of the arc and a value of 1 corresponds to the end point.

Arc3d.point exampleArc 0.5
--> Point3d ( 1.4142, 1.4142, 1 )
sweptAngle : Arc3d -> Float

Get the swept angle of an arc in radians.

Arc2d.sweptAngle exampleArc
--> 1.5708

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.

Transformations

scaleAbout : Point3d -> Float -> Arc3d -> Arc3d

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

point =
    Point3d ( 1, 0, 1 )


Arc3d.scaleAbout point 2 exampleArc
--> Arc3d
-->     { axis =
-->         Axis3d
-->             { originPoint = Point3d ( -1, 0, -1 )
-->             , direction = Direction3d.z
-->             }
-->     , startPoint = Point3d ( 3, 0, 1 )
-->     , sweptAngle = degrees 90
-->     }
rotateAround : Axis3d -> Float -> Arc3d -> Arc3d

Rotate an arc around a given axis by a given angle (in radians).

Arc3d.rotateAround Axis3d.x (degrees 90) exampleArc
--> Arc3d
-->     { axis = Axis3d.flip Axis3d.y
-->     , startPoint = Point3d ( 2, -1, 0 )
-->     , sweptAngle = degrees 90
-->     }
translateBy : Vector3d -> Arc3d -> Arc3d

Translate an arc by a given displacement.

displacement =
    Vector3d ( 2, 1, 3 )


Arc3d.translateBy displacement exampleArc
--> Arc3d
-->     { axis =
-->         Axis3d
-->             { originPoint = Point3d ( 2, 1, 3 )
-->             , direction = Direction3d.z
-->             }
-->     , startPoint = Point3d ( 4, 1, 4 )
-->     , sweptAngle = degrees 90
-->     }
mirrorAcross : Plane3d -> Arc3d -> Arc3d

Mirror an arc across a given plane.

Arc3d.mirrorAcross Plane3d.xy exampleArc
Arc3d
    { axis = Axis3d.flip Axis3d.z
    , startPoint = Point3d ( 2, 0, -1 )
    , sweptAngle = degrees -90
    }

Note that this flips the sign of the arc's swept angle.

Coordinate frames

relativeTo : Frame3d -> Arc3d -> Arc3d

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

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


Arc3d.relativeTo localFrame exampleArc
--> Arc3d
-->     { axis =
-->         Axis3d
-->             { originPoint = Point3d ( -1, -2, -3 )
-->             , direction = Direction3d.z
-->             }
-->     , startPoint = Point3d ( 1, -2, -2 )
-->     , sweptAngle = degrees 90
-->     }
placeIn : Frame3d -> Arc3d -> Arc3d

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

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


Arc3d.placeIn localFrame exampleArc
--> Arc3d
-->     { axis =
-->         Axis3d
-->             { originPoint = Point3d ( 1, 2, 3 )
-->             , direction = Direction3d.z
-->             }
-->     , startPoint = Point3d ( 3, 2, 4 )
-->     , sweptAngle = degrees 90
-->     }