<frustum-matrix4> ( xy-dim near far -- matrix )
Extra matrix operations

Prev:<vandermonde-matrix> ( u n -- matrix )
Next:<ortho-matrix4> ( factors -- matrix )


Vocabulary
math.matrices.extras

Inputs
xy-dima pair
neara number
fara number


Outputs
matrixa matrix


Word description
Make a 4 x 4 matrix suitable for representing an occlusion frustum. A viewing or occlusion frustum is the three-dimensional region of a three-dimensional object which is visible on the screen. See frustum on Wikipedia.

Notes
Only the first two values in xy-dim are used.

Examples
USING: math.matrices.extras prettyprint ; { 5 4 } 5 6 <frustum-matrix4> .
{ { 1.0 0.0 0.0 0.0 } { 0.0 1.25 0.0 0.0 } { 0.0 0.0 -11.0 -60.0 } { 0.0 0.0 -1.0 0.0 } }


See also
glFrustum

Definition


:: <frustum-matrix4> ( xy-dim near far -- matrix )
xy-dim first2 :> ( x y ) near x /f :> xf near y /f
:> yf near far + near far - /f :> zf 2 near far * *
near far - /f :> wf {
{ xf 0.0 0.0 0.0 }
{ 0.0 yf 0.0 0.0 }
{ 0.0 0.0 zf wf }
{ 0.0 0.0 -1.0 0.0 }
} ;