Game Development Reference

In-Depth Information

// Calculate the clip-space corner point opposite the clipping plane

// using Equation (5.64) and transform it into camera space by

// multiplying it by the inverse of the projection matrix.

q.x = (sgn(clipPlane.x) + matrix[8]) / matrix[0];

q.y = (sgn(clipPlane.y) + matrix[9]) / matrix[5];

q.z = -1.0F;

q.w = (1.0F + matrix[10]) / matrix[14];

// Calculate the scaled plane vector using Equation (5.68)

// and replace the third row of the projection matrix.

Vector4D c = clipPlane * (2.0F / Dot(clipPlane, q));

matrix[2] = c.x;

matrix[6] = c.y;

matrix[10] = c.z + 1.0F;

matrix[14] = c.w;

// Load it back into OpenGL.

glMatrixMode(GL_PROJECTION);

glLoadMatrix(matrix);

}

Chapter 5 Summary

Lines

A line passing through the point
P
and running parallel to the direction
V
is ex-

pressed as

()

PP

t

=+

t

.

0

()

The distance from a point
Q
to the line

P

t

is given by

[

(

)

]

QP V

V
−⋅

2

2

0

(

)

d

=

QP

−

−

.

0

2

Planes

A plane having normal direction
N
and containing the point
P
is expressed as

N P

⋅+ =

0

,

D

Search Nedrilad ::

Custom Search