ianmackenzie / elm-geometry-linear-algebra-interop / Geometry.Interop.LinearAlgebra.Point3d

Conversion and transformation functions for Point3d.

toVec3 : Point3d units coordinates -> Math.Vector3.Vec3

Convert a Point3d to a Vec3.

Point3d.toVec3 (Point3d.meters 2 1 3)
--> Vector3.vec3 2 1 3

toVec4 : Point3d units coordinates -> Math.Vector4.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.meters 2 1 3)
--> vec4 2 1 3 1

fromVec3 : Math.Vector3.Vec3 -> Point3d units coordinates

Convert a Vec3 to a Point3d.

Point3d.fromVec3 (vec3 2 1 3)
--> Point3d.unsafe { x = 2, y = 1, z = 3 }

transformBy : Math.Matrix4.Mat4 -> Point3d units1 coordinates1 -> Point3d units2 coordinates2

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

matrix =
    Matrix4.makeTranslate3 3 4 5

Point3d.transformBy matrix point
--> Point3d.meters 5 5 8