ianmackenzie / elm-geometry / Plane3d

A Plane3d is an infinite flat plane in 3D. It is defined by an origin point and normal direction and is useful for several operations including:


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

Constants

xy : Plane3d units coordinates

The global XY plane, centered at the origin with a normal in the positive Z direction.

Plane3d.xy
--> Plane3d.through Point3d.origin Direction3d.z

yz : Plane3d units coordinates

The global YZ plane, centered at the origin with a normal in the positive X direction.

Plane3d.yz
--> Plane3d.through Point3d.origin Direction3d.x

zx : Plane3d units coordinates

The global ZX plane, centered at the origin with a normal in the positive Y direction.

Plane3d.zx
--> Plane3d.through Point3d.origin Direction3d.y

Constructors

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

Construct a plane through the given point, with the given normal direction.

xyPlane =
    Plane3d.through Point3d.origin Direction3d.z

withNormalDirection : Direction3d coordinates -> Point3d units coordinates -> Plane3d units coordinates

Construct a plane with the given normal direction, through the given point. Flipped version of through.

plane =
    Plane3d.withNormalDirection Direction3d.y
        (Point3d.meters 2 1 3)

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

Attempt to construct a plane passing through the three given points. The origin point of the resulting plane will be equal to the first given point, and the normal direction will be such that the three given points are in counterclockwise order around it according to the right-hand rule. If the three given points are collinear, returns Nothing.

Plane3d.throughPoints
    (Point3d.meters 2 0 0)
    (Point3d.meters 3 0 0)
    (Point3d.meters 4 1 1)
--> Just <|
-->     Plane3d.through (Point3d.meters 2 0 0)
-->         (Direction3d.yz (Angle.degrees 135))

Plane3d.throughPoints
    (Point3d.meters 2 0 0)
    (Point3d.meters 3 0 0)
    (Point3d.meters 4 0 0)
--> Nothing

Properties

originPoint : Plane3d units coordinates -> Point3d units coordinates

Get the origin point of a plane.

normalDirection : Plane3d units coordinates -> Direction3d coordinates

Get the normal direction of a plane.

normalAxis : Plane3d units coordinates -> Axis3d units coordinates

Construct an axis from the origin point and normal direction of a plane.

Plane3d.normalAxis Plane3d.zx
--> Axis3d.y

Transformations

offsetBy : Quantity Basics.Float units -> Plane3d units coordinates -> Plane3d units coordinates

Shift a plane in its own normal direction by the given (signed) distance.

Plane3d.offsetBy (Length.meters 1) Plane3d.zx
--> Plane3d.withNormalDirection Direction3d.y
-->     (Point3d.meters 0 1 0)

Plane3d.offsetBy (Length.meters -2) Plane3d.xy
--> Plane3d.withNormalDirection Direction3d.z
-->     (Point3d.meters 0 0 -2)

flip : Plane3d units coordinates -> Plane3d units coordinates

Reverse a plane's normal direction while leaving its origin point unchanged.

reverseNormal : Plane3d units coordinates -> Plane3d units coordinates

Alias for flip, for consistency with Frame3d.reverseX etc.

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

Rotate a plane around an axis by a given angle.

Plane3d.xy
    |> Plane3d.rotateAround Axis3d.y (Angle.degrees 90)
--> Plane3d.yz

translateBy : Vector3d units coordinates -> Plane3d units coordinates -> Plane3d units coordinates

Translate a plane by a given displacement. Applies the given displacement to the plane's origin point and leaves its normal direction unchanged.

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

Translate a plane in a given direction by a given distance.

moveTo : Point3d units coordinates -> Plane3d units coordinates -> Plane3d units coordinates

Move a plane so that it has the given origin point but unchanged normal direction.

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

Mirror one plane across another. The plane to mirror across is given first and the plane to mirror is given second.

plane =
    Plane3d.withNormalDirection Direction3d.z
        (Point3d.meters 1 2 3)

Plane3d.mirrorAcross Plane3d.xy plane
--> Plane3d.withNormalDirection Direction3d.negativeZ
-->     (Point3d.meters 1 2 -3)

Unit conversions

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

Convert a plane 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) -> Plane3d units1 coordinates -> Plane3d units2 coordinates

Convert a plane 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 } -> Plane3d units globalCoordinates -> Plane3d units localCoordinates

Take a plane 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 } -> Plane3d units localCoordinates -> Plane3d units globalCoordinates

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