glFrustumとgluPerspective
OpenGLの透視投影の指定はhttp://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml (glFrustum)で行う。
glFrustum(left, right, bottom, top, near, far)
もうひとつこれの簡易版としてhttp://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml (gluPerspective)があって
gluPerspective(fovy, aspect, near, far)
となっている。
(fovyは「Field Of View. Yの」くらいの意味。)
glFrustumの行列は、
のように定義される。
このうちAとBはgluPerspectiveでは常に0になる。
左右対称(left+right=0)かつ上下対称(top+bottom=0)だからです。
これを代入すると
となる。
一方、gluPerspectiveの行列は、
と定義される。
gluPerspectiveのfに対応するglFrustumの
とするとcotangentの定義そのまま。
もう1つのf/aspectの方もそういうことで2式は等価になった。
gluPerspectiveはglFrustumの上下対称左右対称限定版で、
引数の取り方をちょっと変更したものと言える。
texに慣れてきたところで次回に投影行列の中身に入る。