The orthographic projection matrix takes a rectangular prism with corners at (l, t, -n) and (r, b, -f) (with l being left, t being top, n being near, r being right, b being bottom, and f being far) and maps it to a cube with the coordinates of the same corners being (-1, 1, 1) and (1, -1, -1)

Achieving this is going to take a scale and a translate on each axis. To solve for the scale in x and translation in x we have the system of equations:

So we have that then we have that

With exactly the same algebra we can obtain and

Then for the z-axis we have the system of equations:

which, with the same algebra as before, leads to the solutions and

So putting all of that together we get the final matrix: