ianmackenzie / elm-geometry / 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 units coordinates =
Geometry.Types.Axis3d units coordinates

Constants

x : Axis3d units coordinates

The global X axis.

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

y : Axis3d units coordinates

The global Y axis.

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

z : Axis3d units coordinates

The global Z axis.

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

Constructors

through : Point3d units coordinates -> Direction3d coordinates -> Axis3d units coordinates

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

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

withDirection : Direction3d coordinates -> Point3d units coordinates -> Axis3d units coordinates

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

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

Attempt to construct an axis through the two given points;

Axis3d.throughPoints p1 p2

is equivalent to

Maybe.map (Axis3d.through firstPoint)
    (Direction3d.from firstPoint secondPoint)

on : Geometry.Types.SketchPlane3d units coordinates3d { defines : coordinates2d } -> Axis2d units coordinates2d -> Axis3d units coordinates3d

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.meters 1 3)
        (Direction2d.degrees 30)

Axis3d.on SketchPlane3d.xy axis2d
--> Axis3d.through (Point3d.meters 1 3 0)
-->     (Direction3d.xy (Angle.degrees 30))

Axis3d.on SketchPlane3d.zx axis2d
--> Axis3d.through (Point3d.meters 3 0 1)
-->     (Direction3d.zx (Angle.degees 30))

Properties

originPoint : Axis3d units coordinates -> Point3d units coordinates

Get the origin point of an axis.

direction : Axis3d units coordinates -> Direction3d coordinates

Get the direction of an axis.

Intersection

intersectionWithPlane : Geometry.Types.Plane3d units coordinates -> Axis3d units coordinates -> Maybe (Point3d units coordinates)

Try to find the unique intersection point of an axis with a plane. If the axis does not intersect the plane, or if it is coplanar with it (lying perfectly in the plane), returns Nothing.

intersectionWithTriangle : Geometry.Types.Triangle3d units coordinates -> Axis3d units coordinates -> Maybe (Point3d units coordinates)

Try to find the unique intersection point of an axis with a triangle. If the axis does not intersect the triangle, or if it is coplanar with it (lying perfectly in the plane of the triangle), returns Nothing.

intersectionWithRectangle : Geometry.Types.Rectangle3d units coordinates -> Axis3d units coordinates -> Maybe (Point3d units coordinates)

Try to find the unique intersection point of an axis with a rectangle. If the axis does not intersect the rectangle, or if it is coplanar with it (lying perfectly in the plane of the rectangle), returns Nothing.

intersectionWithSphere : Geometry.Types.Sphere3d units coordinates -> Axis3d units coordinates -> Maybe ( Point3d units coordinates, Point3d units coordinates )

Attempt to find the intersection of an axis with a sphere. The two points will be in order of signed distance along the axis. Returns Nothing if there is no intersection.

Transformations

reverse : Axis3d units coordinates -> Axis3d units coordinates

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

moveTo : Point3d units coordinates -> Axis3d units coordinates -> Axis3d units coordinates

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

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

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.

exampleAxis
    |> Axis3d.rotateAround Axis3d.z
        (Angle.degrees 90)
--> Axis3d.withDirection Direction3d.negativeX
-->     (Point3d.meters -2 1 3)

translateBy : Vector3d units coordinates -> Axis3d units coordinates -> Axis3d units coordinates

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

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

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

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

Mirror an axis across a plane.

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

projectOnto : Geometry.Types.Plane3d units coordinates -> Axis3d units coordinates -> Maybe (Axis3d units coordinates)

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.meters 1 2 0)

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

Unit conversions

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

Convert an axis 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) -> Axis3d units1 coordinates -> Axis3d units2 coordinates

Convert an axis 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 : Geometry.Types.Frame3d units globalCoordinates { defines : localCoordinates } -> Axis3d units globalCoordinates -> Axis3d units localCoordinates

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

placeIn : Geometry.Types.Frame3d units globalCoordinates { defines : localCoordinates } -> Axis3d units localCoordinates -> Axis3d units globalCoordinates

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

projectInto : Geometry.Types.SketchPlane3d units coordinates3d { defines : coordinates2d } -> Axis3d units coordinates3d -> Maybe (Axis2d units coordinates2d)

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.meters 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.meters 2 3)

Axis3d.projectInto SketchPlane3d.xz exampleAxis
--> Nothing