ianmackenzie / elm-geometry-prerelease / Axis3d

An Axis3d represents an infinitely long straight line in 3D and is defined by an origin point and direction. Axes have several uses, such as:


type alias Axis3d =
Geometry.Types.Axis3d

Constants

x : Axis3d

The global X axis.

Axis3d.x
--> Axis3d.through Point3d.origin Direction3d.x

y : Axis3d

The global Y axis.

Axis3d.y
--> Axis3d.through Point3d.origin Direction3d.y

z : Axis3d

The global Z axis.

Axis3d.z
--> Axis3d.through Point3d.origin Direction3d.z

Constructors

through : Point3d -> Direction3d -> Axis3d

Construct an axis through the given point, with the given direction.

exampleAxis =
    Axis3d.through
        (Point3d.fromCoordinates ( 1, 2, 3 ))
        Direction3d.y

withDirection : Direction3d -> Point3d -> Axis3d

Construct an axis with the given directoin, through the given point. Flipped version of through. Having both versions allow you to do different things with partial application:

-- A list of axes in different directions all passing
-- through the same origin point
List.map (Axis3d.through point) directions


-- A list of parallel axes (all having the same
-- direction) through different points
List.map (Axis3d.withDirection direction) points

on : Geometry.Types.SketchPlane3d -> Axis2d -> Axis3d

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

axis2d =
    Axis2d.through (Point2d.fromCoordinates ( 1, 3 ))
        (Direction2d.fromAngle (degrees 30))

Axis3d.on SketchPlane3d.xy axis2d
--> Axis3d.through
-->     (Point3d.fromCoordinates ( 1, 3, 0 ))
-->     (Direction3d.fromAzimuthAndElevation
-->         (degrees 30)
-->         (degrees 0)
-->     )

Axis3d.on SketchPlane3d.zx axis2d
--> Axis3d.through
-->     (Point3d.fromCoordinates ( 3, 0, 1 ))
-->     (Direction3d.fromAzimuthAndElevation
-->         (degrees 0)
-->         (degrees 60)
-->     )

Properties

originPoint : Axis3d -> Point3d

Get the origin point of an axis.

Axis3d.originPoint exampleAxis
--> Point3d.fromCoordinates ( 1, 2, 3 )

direction : Axis3d -> Direction3d

Get the direction of an axis.

Axis3d.direction exampleAxis
--> Direction3d.y

Transformations

reverse : Axis3d -> Axis3d

Reverse the direction of an axis while keeping the same origin point.

Axis3d.reverse exampleAxis
--> Axis3d.withDirection Direction3d.negativeY
-->     (Point3d.fromCoordinates ( 1, 2, 3 ))

moveTo : Point3d -> Axis3d -> Axis3d

Move an axis so that it has the given origin point but unchanged direction.

newOrigin =
    Point3d.fromCoordinates ( 3, 4, 5 )

Axis3d.moveTo newOrigin exampleAxis
--> Axis3d.withDirection Direction3d.y
-->     (Point3d.fromCoordinates ( 3, 4, 5 ))

rotateAround : Axis3d -> Basics.Float -> Axis3d -> Axis3d

Rotate an axis around another axis by a given angle. The axis to rotate around is given first and the axis to rotate is given last.

Axis3d.rotateAround Axis3d.z (degrees 90) exampleAxis
--> Axis3d.withDirection Direction3d.negativeX
-->     (Point3d.fromCoordinates ( -2, 1, 3 ))

translateBy : Vector3d -> Axis3d -> Axis3d

Translate an axis by a given displacement. Applies the given displacement to the axis' origin point and leaves the direction unchanged.

displacement =
    Vector3d.fromComponents ( 3, 3, 3 )

Axis3d.translateBy displacement exampleAxis
--> Axis3d.withDirection Direction3d.y
-->     (Point3d.fromCoordinates ( 4, 5, 6 ))

translateIn : Direction3d -> Basics.Float -> Axis3d -> Axis3d

Translate an axis in a given direction by a given distance;

Axis3d.translateIn direction distance

is equivalent to

Axis3d.translateBy
    (Vector3d.withLength distance direction)

mirrorAcross : Geometry.Types.Plane3d -> Axis3d -> Axis3d

Mirror an axis across a plane.

Axis3d.mirrorAcross Plane3d.xy exampleAxis
--> Axis3d.withDirection Direction3d.y
-->     (Point3d.fromCoordinates ( 1, 2, -3 ))

projectOnto : Geometry.Types.Plane3d -> Axis3d -> Maybe Axis3d

Find the orthographic projection of an axis onto a plane. If the given axis is exactly perpendicular to the given plane, returns Nothing.

Axis3d.projectOnto Plane3d.xy exampleAxis
--> Just
-->     (Axis3d.withDirection Direction3d.y
-->         (Point3d.fromCoordinates ( 1, 2, 0 ))
-->     )

Axis3d.projectOnto Plane3d.xy Axis3d.z
--> Nothing

Coordinate conversions

relativeTo : Geometry.Types.Frame3d -> Axis3d -> Axis3d

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

localFrame =
    Frame3d.atPoint
        (Point3d.fromCoordinates ( 3, 3, 3 ))

Axis3d.relativeTo localFrame exampleAxis
--> Axis3d.withDirection Direction3d.y
-->     (Point3d.fromCoordinates ( -2, -1, 0 ))

placeIn : Geometry.Types.Frame3d -> Axis3d -> Axis3d

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

localFrame =
    Frame3d.atPoint
        (Point3d.fromCoordinates ( 3, 3, 3 ))

Axis3d.placeIn localFrame exampleAxis
--> Axis3d.withDirection Direction3d.y
-->     (Point3d.fromCoordinates ( 4, 5, 6 ))

projectInto : Geometry.Types.SketchPlane3d -> Axis3d -> Maybe Axis2d

Project an axis into a given sketch plane. Conceptually, this finds the orthographic projection of the axis onto the plane and then expresses the projected axis in 2D sketch coordinates.

This is only possible if the axis is not perpendicular to the sketch plane; if it is perpendicular, Nothing is returned.

Axis3d.projectInto SketchPlane3d.xy exampleAxis
--> Just
-->     (Axis2d.withDirection Direction2d.y
-->         (Point2d.fromCoordinates ( 1, 2 ))
-->     )

-- The global Y direction is the X direction of the
-- YZ plane:
Axis3d.projectInto SketchPlane3d.yz exampleAxis
--> Just
-->     (Axis2d.withDirection Direction2d.x
-->         (Point2d.fromCoordinates ( 2, 3 ))
-->     )

Axis3d.projectInto SketchPlane3d.xz exampleAxis
--> Nothing