ianmackenzie/elm-geometry-linear-algebra-interop/1.0.1

NOTE: the latest version is 2.0.3

Geometry.Interop.LinearAlgebra.Frame3d

Conversion functions for Frame3d.

toMat4 : Frame3d -> Mat4

Convert a Frame3d to a Mat4. The resulting matrix can be thought of in a couple of ways:

  • It is the transformation matrix that takes the global XYZ frame and transforms it to the given frame
  • It is the transformation matrix from local coordinates in the given frame to global coordinates

The first bullet implies that something like

Frame3d.xyz
    |> Frame3d.translateBy displacement
    |> Frame3d.rotateAround axis angle
    |> Frame3d.mirrorAcross plane
    |> Frame3d.toMat4

gives you a transformation matrix that is equivalent to applying the given displacement, then the given rotation, then the given mirror. The second bullet means that, for example,

Point3d.placeIn frame

is equivalent to

Point3d.transformBy (Frame3d.toMat4 frame)

and

Point3d.relativeTo frame

is equivalent to

Point3d.transformBy <|
    Matrix4.inverseOrthonormal
        (Frame3d.toMat4 frame)