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

NOTE: this package is not compatible with Elm 0.19.1

Geometry.Interop.LinearAlgebra.Point3d

Conversion and transformation functions for Point3d.

toVec3 : Point3d -> Vec3

Convert a Point3d to a Vec3.

Point3d.toVec3 (Point3d.fromCoordinates ( 2, 1, 3 ))
--> Vector3.vec3 2 1 3
toVec4 : Point3d -> Vec4

Convert a Point3d to a Vec4. The resulting Vec4 will have a W component of 1 so that it is affected by translation when performing matrix transformations.

Point3d.toVec4 (Point3d.fromCoordinates ( 2, 1, 3 ))
--> vec4 2 1 3 1
fromVec3 : Vec3 -> Point3d

Convert a Vec3 to a Point3d.

Point3d.fromVec3 (vec3 2 1 3)
--> Point3d.fromCoordinates ( 2, 1, 3 )
transformBy : Mat4 -> Point3d -> Point3d

Transform a Point3d by a Mat4;

point
    |> Point3d.transformBy matrix

is equivalent to

point
    |> Point3d.toVec3
    |> Matrix4.transform matrix
    |> Point3d.fromVec3

For example:

point =
    Point3d.fromCoordinates ( 2, 1, 3 )


matrix =
    Matrix4.makeTranslate3 3 4 5


Point3d.transformBy matrix point
--> Point3d.fromCoordinates ( 5, 5, 8 )