Computer Animation: Algorithms and Techniques
29
. (EQ 1)
w = COI–EYE view direction vector u = w×(0 1 0, , ) cross product with y-axis
v = w×u up vector
30
Computer Animation: Algorithms and Techniques yx z
center of interest
up vector
view vector
observer
Computer Animation: Algorithms and Techniques
31
FIGURE 7. Object to world space transformation and the view frustum in world space.
Object Space
World Space
Object transformed into world space
Center of Interest
Observer
Angle of View Hither Clipping Distance
Yon Clipping Distance
Up V ector
z
x y
z
x y
View Vector
View Frustum
32
Computer Animation: Algorithms and TechniquesFIGURE 8.Display pipeline showing transformation between spaces.
Object Space
World Space
x y
z
y
z
x
y
Eye Space
x
z y
Image Space eye at negative infinity
Screen Space x z
parallel lines of sight lines of sight
emanating from observer
x y
Computer Animation: Algorithms and Techniques
33
.
FIGURE 9. Transformation through spaces using ray casting.
Object Space
World Space y
z
y
x
Screen Space x
z
virtual frame buffer
ray constructed through pixel center
34
Computer Animation: Algorithms and Techniques(EQ 2)
. (EQ 3)
(EQ 4)
(EQ 5)
. (EQ 6)
(EQ 7)
(EQ 8)
(EQ 9)
x w---- y
w---- z w----
, ,
= [x y z w, , , ]
x y z, ,
( ) = [x y z 1, , , ]
x y z 1
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
=
x y z 1
x y z 1 = x y z 1
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
P' = M1M2M3M4M5M6P M = M1M2M3M4M5M6
P' = MP
P' = PM6TM5TM4TMT3M2TM1T MT = M6TM5TMT4MT3M2TM1T
P' = PMT
x' y' z' 1
a b c d e f g h i j k m 0 0 0 1
x y z 1
=
x+tx y+ty z+tz
1
1 0 0 tx 0 1 0 ty 0 0 1 tz 0 0 0 1
x y z 1
=
Computer Animation: Algorithms and Techniques
35
(EQ 10)
(EQ 11)
(EQ 12)
(EQ 13)
(EQ 14)
Sx⋅x Sy⋅y Sz⋅z 1
Sx 0 0 0 0 Sy 0 0 0 0 Sz 0 0 0 0 1
x y z 1
=
S x⋅ S y⋅ S z⋅ 1
x y z 1 S---
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 S---
= =
x y z 1
x' y' z' 1
1 0 0 0
0 cosθ –sinθ0 0 sinθ cosθ 0
0 0 0 1
x y z 1
=
x' y' z' 1
θ
cos 0 sinθ 0
0 1 0 0
θ sin
– 0 cosθ 0
0 0 0 1
x y z 1
=
x' y' z' 1
θ
cos –sinθ0 0 θ
sin cosθ 0 0
0 0 1 0
0 0 0 1
x y z 1
=
36
Computer Animation: Algorithms and TechniquesFIGURE 10. Desired Position and Orientation.
z
y
x
z
y
x
(20, -10, 35)
(23,-14,40)
a) Object space definition b) World space position and orientation of aircraft up vector
Computer Animation: Algorithms and Techniques
37
.
FIGURE 11. Projection of desired orientation vector onto y-z plane.
Y
Z
(-4,5) -4
5 ψ
38
Computer Animation: Algorithms and Techniques .FIGURE 12. Projection of desired orientation vector onto x-z plane.
Z
X (3,5)
5
3 φ
Computer Animation: Algorithms and Techniques
39
FIGURE 13. Global coordinate system and unit coordinate system to be transformed.
z
y
x
Z
X Y
x,y,z - global coordinate system X,Y,Z - deisred orientation defined by
unit coordinate system
40
Computer Animation: Algorithms and Techniques(EQ 15)
(EQ 16)
(EQ 17)
X = M x⋅ Xx
Xy Xz
M
= 1 0 0
⋅
Y = M y⋅ Yx
Yy Yz
M 0 1 0
⋅
=
Z = M z⋅ Zx
Zy Zz
M 0 0 1
⋅
=
XxYxZx XyYyZy Xz Yz Zz
M
1 0 0 0 1 0 0 0 1
⋅
=
Xx YxZx Xy YyZy Xz Yz Zz
M
=
x' y' z' 1
A11 A12 A13 A14 A21 A22 A23 A24 A31 A32 A33 A34
0 0 0 1
x y z 1
=
Computer Animation: Algorithms and Techniques
41
.
FIGURE 14. Translation of moon out to its initial position on the x-axis.
(r,0,0) x
y
z z
x y
42
Computer Animation: Algorithms and TechniquesFIGURE 15. Rotation by applying incremental rotation matrices to points.
(r,0,0)
1 2 3
Rdy= y-axis rotation of 5 degrees for each point P’ of the moon { record a frame of the animation
P’ = Rdy*P’
for each point P of the moon { P’ = P
z
x y
repeat until (done) {
} } }
Computer Animation: Algorithms and Techniques
43
FIGURE 16. Rotation by incrementally updating the rotation matrix.
(r,0,0) 1 2
3 R = identity matrix
Rdy= y-axis rotation of 5 degrees
R = R*Rdy
record a frame of the animation P’ = R*P
for each point P of the moon { y
x z
repeat until (done) {
}
}
44
Computer Animation: Algorithms and TechniquesFIGURE 17. Rotation by forming the rotation matrix new for each frame.
(r,0,0) 1 2 3
y = 0
record a frame of the animation P’ = R*P
for each point P of the moon {
R = y-axis rotation matrix of ‘y’ degrees
y = y+5 y
x z
repeat until (done) {
} }
Computer Animation: Algorithms and Techniques
45
.
FIGURE 18. Orthonormalization.
Step 1: Normalize one of the vectors
Step 2:
Form vector perpendicular (orthogonal) and to one of the other two original vectors Normalize it.
Step 3:
Form the final orthogonal vector by taking the cross product of the two just generated.
Normalize it.
to the vector just normalized by taking cross product of the two.
the original unit orthogonal vectors each other due to repeated transformations have ceased to be orthogonal from
46
Computer Animation: Algorithms and Techniques .FIGURE 19. Direct interpolation of transformation matrix values can result in nonsense.
0 0 1 0 1 0
1 – 0 0
0 0 –1 0 1 0 1 0 0
a) Positive 90 degree y-axis rotation b) Negative 90 degree y-axis rotation
c) Half way between orientation representations 0 0 0
0 1 0 0 0 0
Computer Animation: Algorithms and Techniques
47
.
FIGURE 20. Fixed angle representation.
z
y
x
z
y
x
48
Computer Animation: Algorithms and TechniquesFIGURE 21. Fixed angle representation of (0,90,0).
x y
z
x y
z
a) Original definition b) (0,90,0) orientation
Computer Animation: Algorithms and Techniques
49
.
FIGURE 22. Effect of slightly altering values of fixed angle representation (0,90,0).
x y
z (+/-ε,90,0) orientation
x y
z
(0,90+/-ε,0) orientation
x y
z
(0,90,+/-ε) orientation
a) b) c)
50
Computer Animation: Algorithms and TechniquesFIGURE 23. Example orientations to interpolate.
x y
z
(0,90,0) orientation
x y
z
(90,45,90) orientation; the object lies in the y-z plane
Computer Animation: Algorithms and Techniques
51
.
FIGURE 24. Euler angle representation.
X Y
Z
x y
z
Global coordinate system
Local Coordinate system attached to object yaw
pitch roll
52
Computer Animation: Algorithms and Techniques(EQ 18)
(EQ 19)
Ry'( )Rβ x( )α = Rx( )Rα y( )Rβ x( )Rα x(–α)= Rx( )Rα y( )β
Rz''( )Rγ y'( )Rβ x( )α = Rx( )Rα y( )Rβ z( )Rγ y(–α)Rx(–β)Ry( )Rβ x( )α = Rx( )Rα y( )Rβ z( )γ
Computer Animation: Algorithms and Techniques
53
FIGURE 25. Euler’s Rotation Theorem implies that, for any two orientations of an object, one can be produced from the other by a single rotation about an arbitrary axis.
X Y
Z
X Y
Z
θ
orientation A orientation B
angle and axis of rotation
54
Computer Animation: Algorithms and Techniques!
FIGURE 26. Interpolating axis-angle representations.
X Y
Z
θ1
Α1
Α2 θ2
B=A1xA2
φ φ cos–1 A1•A2
A1 A2 ---
=
Ak = RB(k⋅φ) A1 θk = (1–k) θ⋅ 1+k⋅θ2
B = A1×A2
Computer Animation: Algorithms and Techniques
55
.
(EQ 20)
(EQ 21)
(EQ 22)
(EQ 23)
(EQ 24)
(EQ 25)
(EQ 26)
(EQ 27)
(EQ 28)
27.
s1,v1
[ ]⋅[s2,v2] = [s1⋅s2–v1•v2,s1⋅v2+s2⋅v1+v1×v2]
0 v, 1
[ ]⋅[0 v, 2] = [0 v, 1×v2] iff v1•v2 = 0
q–1 = (1⁄ q )2⋅[s,–v] where q = s2+x2+y2+z2
q⁄ q
q⁄( q )
v' = Rot v( ) = q–1⋅ ⋅v q
Rotq(Rotp( )v) = q–1⋅(p–1⋅ ⋅v p)⋅q ( )pq –1⋅ ⋅v ( )pq
( )
=
Rotpq( )v
=
Rot–1(Rot v( )) = q⋅(q–1⋅ ⋅v q)⋅q–1 = v
q = Rotθ,(x y z, , ) = [cos(θ⁄2),sin(θ⁄2)⋅(x y z, , )]
q
– = Rot–θ,–(x y z, , ) θ – ⁄2
( )
cos ,sin(( )–θ ⁄2)⋅(–(x y z, , ))
[ ]
=
θ⁄2
( )
cos ,–sin(θ⁄2)⋅(–(x y z, , ))
[ ]
=
θ⁄2
( )
cos ,sin(θ⁄2)⋅x y z, ,
[ ]
=
Rotθ,(x y z, , )
= q
=