8

I've been looking around a bit and can't seem to find just what I"m looking for. I've found "canonical formulas," but what's the best way to use these? Do I have to scale every single vertex down? Or is there a better way?

A formula would really help me out, but I'm also looking for an explanation about the near and far z planes relative the viewer's position

Bob Cross
  • 22,116
  • 12
  • 58
  • 95
Chad
  • 2,335
  • 8
  • 29
  • 45
  • You might get a better response if you ask more specifically - this is pretty general. Give an example of what the input to the formula is, and what the expected output is. This is in the realm of linear algebra, so that might give you more google fodder. – Adam Davis Mar 27 '09 at 02:06

2 Answers2

9

Here is a reasonable source that derives an orthogonal project matrix:

Consider a few points: First, in eye space, your camera is positioned at the origin and looking directly down the z-axis. And second, you usually want your field of view to extend equally far to the left as it does to the right, and equally far above the z-axis as below. If that is the case, the z-axis passes directly through the center of your view volume, and so you have r = –l and t = –b. In other words, you can forget about r, l, t, and b altogether, and simply define your view volume in terms of a width w, and a height h, along with your other clipping planes f and n. If you make those substitutions into the orthographic projection matrix above, you get this rather simplified version:

All of the above gives you a matrix that looks like this (add rotation and translation as appropriate if you'd like your resulting transformation matrix to treat an arbitrary camera position and orientation).

A LaTeX rendering of the orthographic projection matrix
(source: codeguru.com)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Bob Cross
  • 22,116
  • 12
  • 58
  • 95