Game Development Reference
In-Depth Information
y
y'
x'
θ
x
Figure 6-7. Rotating a coordinate system by an angle
If you recall from Chapter 1, to determine the velocity components in the rotated (line-of-
action-aligned) coordinate system, the original velocity components v x and v y are multiplied
by the rotation matrix shown in Equation (6.17).
v
v
cos
θ
sin
θ
x
p
=
(6.17)
v
−θ
sin
cos
θ
v
n
y
The velocity v n is the velocity component normal to the line of action. The normal velocity
component will be unaffected by the collision, and its value is given by Equation (6.18).
v
=−
v
sin
θ+
v
cos
θ
(6.18)
n
x
y
Once the velocity components v p and v n have been determined, the post-collision velocity
along the line of action, v
p , can be computed from Equation (6.14). Once the post-collision
velocities have been determined, it is usually desirable to convert the rotated velocities back
into the original Cartesian velocity components. To do this, the rotated velocity components
are multiplied by the inverse rotation matrix shown in Equation (6.19).
v
cos
θ− θ
sin
v
x
p
=
(6.19)
v
sin
θ
cos
θ
v
⎦ ⎣
y
n
The equations represented by the matrix in Equation (6.19) are shown in Equation (6.20).
=θ −θ
vv
cos
v
sin
(6.20a)
x
p
n
=θ +θ
vv
sin
v
cos
(6.20b)
y
p
n
Search WWH ::




Custom Search