Game Development Reference

In-Depth Information

where

==

sc θ

tan

. Applying the quadratic formula, we have

t

2

t

=− ±

uu

+

1

.

(16.48)

For best numerical stability, we want to choose the smaller of the two angles of

rotation represented by this equation. The smaller value of
t
is given by

()
(

)

2

t

=

sgn

uu

+

1

−

u

.

(16.49)

()

2

u

(In this case, we need

sgn 0

=

1

so that

=

1

when

=

0

.) If
u
is so large that

t

u

()

produces a floating-point infinity (possible when

θ

≈

0

), we assign

=

12

u

be-

t

cause

2

()

(

)

u

++

1

u

sgn

u

()

2

sgn

uu

+−

1

u

u

=

(16.50)

2

2

++

1

u

u

++

1

u

and

2

u

+

1

lim

=

1

.

(16.51)

u

u

→∞

Using the identity

(see Appendix B, Section B.3), we can now com-

pute the values of
c
and
s
as follows.

2

2

t

+=

11

c

1

c

=

2

t

+

1

s

=

ct

(16.52)

′

When calculating the entries of

M
, we simply assume that

′

=

0

. We can

M

pq

then solve Equation (16.43) for

and

:

M

M

pp

qq

2

2

sc

−

M

=+

M

M

pp

qq

pq

sc

sc

2

2

−

M

=

M

−

M

.

(16.53)

qq

pp

pq

sc

Plugging this value of

into Equation (16.41) and this value of

into

M

M

qq

pp

Equation (16.42) gives us the much simpler expressions

Search Nedrilad ::

Custom Search