setOrthographicMatrix function
Constructs an OpenGL orthographic projection matrix in orthographicMatrix
.
left
, right
specify the coordinates for the left and right vertical
clipping planes.
bottom
, top
specify the coordinates for the bottom and top horizontal
clipping planes.
near
, far
specify the coordinates to the near and far depth clipping
planes.
Implementation
void setOrthographicMatrix(Matrix4 orthographicMatrix, double left,
double right, double bottom, double top, double near, double far) {
final double rml = right - left;
final double rpl = right + left;
final double tmb = top - bottom;
final double tpb = top + bottom;
final double fmn = far - near;
final double fpn = far + near;
orthographicMatrix
..setZero()
..setEntry(0, 0, 2.0 / rml)
..setEntry(1, 1, 2.0 / tmb)
..setEntry(2, 2, -2.0 / fmn)
..setEntry(0, 3, -rpl / rml)
..setEntry(1, 3, -tpb / tmb)
..setEntry(2, 3, -fpn / fmn)
..setEntry(3, 3, 1.0);
}