Game Development Reference
In-Depth Information
2
3
1
0
0
4
5
P xy = S
0
0
1
,0
=
0
1
0
,
Projecting onto a
cardinal plane
0
0
0
2
3
1
0
0
4
5
P xz = S
0
1
0
,0
=
0
0
0
,
0
0
1
2
3
0
0
0
4
5
P yz = S
1
0
0
,0
=
0
1
0
.
0
0
1
5.3.2
Projecting onto an Arbitrary Line or Plane
We can also project onto any arbitrary line (in 2D) or plane (in 3D). As
before, since we are not considering translation, the line or plane must pass
through the origin. The projection will be defined by a unit vector n that
is perpendicular to the line or plane.
We can derive the matrix to project in an arbitrary direction by applying
a zero scale factor along this direction, using the equations we developed
in Section 5.2.2. In 2D, we have
1 + (0 − 1)n x 2
(0 − 1)n x n y
2D matrix to project
onto an arbitrary line
P ( n ) = S ( n ,0) =
1 + (0 − 1)n y 2
(0 − 1)n x n y
1 − n x 2
−n x n y
=
.
1 − n y 2
−n x n y
Remember that n is perpendicular to the line onto which we are pro-
jecting, not parallel to it. In 3D, we project onto the plane perpendicular
to n :
2
3
1 + (0 − 1)n x 2
(0 − 1)n x n y
(0 − 1)n x n z
3D matrix to project
onto an arbitrary plane
4
5
1 + (0 − 1)n y 2
P ( n ) = S ( n ,0) =
(0 − 1)n x n y
(0 − 1)n y n z
1 + (0 − 1)n z 2
(0 − 1)n x n z
(0 − 1)n y n z
2
3
1 − n x 2
−n x n y
−n x n z
4
5
1 − n y 2
=
−n x n y
−n y n z
.
1 − n z 2
−n x n z
−n y n z
 
Search WWH ::




Custom Search