removePerspectiveTransform static method

Matrix4 removePerspectiveTransform(
  1. Matrix4 transform
)

Removes the "perspective" component from transform.

When applying the resulting transform matrix to a point with a z-coordinate of zero (which is generally assumed for all points represented by an Offset), the other coordinates will get transformed as before, but the new z-coordinate is going to be zero again. This is achieved by setting the third column and third row of the matrix to "0, 0, 1, 0".

Implementation

static Matrix4 removePerspectiveTransform(Matrix4 transform) {
  final Vector4 vector = Vector4(0, 0, 1, 0);
  return transform.clone()
    ..setColumn(2, vector)
    ..setRow(2, vector);
}