makePlaneProjection function
Returns a transformation matrix that transforms points onto
the plane specified with planeNormal
and planePoint
.
Implementation
Matrix4 makePlaneProjection(Vector3 planeNormal, Vector3 planePoint) {
final Vector4 v = new Vector4(planeNormal.storage[0], planeNormal.storage[1],
planeNormal.storage[2], 0.0);
final Matrix4 outer = new Matrix4.outer(v, v);
Matrix4 r = new Matrix4.zero();
r = r - outer;
final Vector3 scaledNormal =
(planeNormal.scaled(dot3(planePoint, planeNormal)));
final Vector4 T = new Vector4(scaledNormal.storage[0],
scaledNormal.storage[1], scaledNormal.storage[2], 1.0);
r.setColumn(3, T);
return r;
}