Table Of Contents

Previous topic

スキニング高速化

Next topic

glFrustnum

This Page

gluPerspective

Note

列ベクトル方式で説明

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

(gluPersepective)があって

gluPerspective(fovy, aspect, near, far)

となっている。 fovyは「Field Of View in the Y direction.」くらいの意味。Field of viewは視野角なので縦方向の視野角を意味する。単位は度。

glFrustumの行列は、

\left( \begin{array}{cccc} \frac{2 \cdot near}{right - left}  & 0 & A & 0 \\
    0 & \frac{2 \cdot near}{top - bottom} & B & 0 \\
    0 & 0 &  C & D \\
    0 & 0 & -1 & 0 \end{array} \right) \\

A = \frac{right + left}{right - left}

B = \frac{top + bottom}{top - bottom}

C = - \frac{far + near}{far - near}

D = - \frac{2 \cdot far \cdot near}{far - near}

のように定義される。 このうちAとBはgluPersepectiveでは常に0になる。 左右対称(left+right=0)かつ上下対称(top+bottom=0)だからです。

これを代入すると

\left( \begin{array}{cccc} \frac{2 \cdot near}{right - left}  & 0 & 0 & 0 \\
0 & \frac{2 \cdot near}{top - bottom} & 0 & 0 \\
0 & 0 & - \frac{far + near}{far - near} & - \frac{2 \cdot far \cdot near}{far - near} \\
0 & 0 & -1 & 0 \end{array} \right)

となる。 一方、gluPersepectiveの行列は、

\left( \begin{array}{cccc} \frac{f}{aspect}  & 0 & 0 & 0 \\
0 & f & 0 & 0 \\
0 & 0 & \frac{far + near}{near - far} & \frac{2 \cdot far \cdot near}{near - far} \\
0 & 0 & -1 & 0 \end{array} \right) \\
f = \cot \left( \frac{fovy}{2} \right)

と定義される。 gluPersepectiveのfに対応するglFrustumの

\frac{2 \cdot near}{top - bottom} \\
\frac{near}{ height/2 } = \frac{\cos}{\sin}

とするとcotangentの定義そのまま。 もう1つのf/aspectの方もそういうことで2式は等価になった。

gluPersepectiveはglFrustumの上下対称左右対称限定版で、 引数の取り方をちょっと変更したものと言える。

inserted by FC2 system