3D Transformations & Orientation Parameterization: Advanced Computer Animation Techniques Aug-Dec 2011 Cesteves@cimat - MX
3D Transformations & Orientation Parameterization: Advanced Computer Animation Techniques Aug-Dec 2011 Cesteves@cimat - MX
3D coordinate systems
There is no series of pure rotations that transforms left-handed conguration of axes into a right-handed conguration. Another arbitrary convention is the axis to use as the up vector. Some applications use the y-axis as the up vector, some use the z-axis.
2
3D Display Pipeline
Transformation of object data from its original dening space through a series of intermediate spaces until its nal mapping onto the screen. The object is originally dened in the object space. The origin is generally some point inside the object. Vertices of the object are transformed (using rotations, translations, scales) into world space with a common origin for all the objects. Object and world spaces commonly use a right-handed coordinate convention. Lights and observer (camera or eye) are placed in world space coordinates. The view direction can be specied by giving a center of interest (COI) in which case the view direction is the vector from the observer or eye position (EYE) to the COI. Objects, lights and observer are converted into camera relative coordinates or view space (u,v,w) with:
w = COI EYE
3D Display Pipeline
Field of view (FOV), includes an angle of view, near and far clipping distances. Used for perspective projection. Orientation of the projection plane.
Perform perspective or orthographic projection to transform from view space to image space.
4
OCS
Modelo Escena 3D M1 Modelo M2 V Vista de la escena 3D
Mn Modelo
WCS
VCS
Rasterization
Despliegue
Clip
Normalizar
ICS
3D Transformations
In CG points are often represented in an homogeneous space with a four element vector for a 3D point: x y z , , = [x, y, z, w] w w w The basic transformations of rotate, translate, and scale can be kept in 4x4 transformation matrices. Here, a point will be represented as a 4x1 column matrix (column vector) and is transformed by multiplying by a 4x4 matrix on the left:
x 1 y 0 = z 0 1 0 0 1 0 0 0 0 1 0 0 x 0 y 0 z 1 1
6
3D Transformations
If the point was represented as a row vector:
1 0 [ x y z 1 ] = [ x y z 1 ] 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Transformations are concatenated to produced compound transformations. Remember that matrix multiplication is associative ((AB)C = A(BC)) but not commutative (ABBA).
P = M1 M2 M3 M4 M5 M6 P M = M1 M2 M3 M4 M5 M6 P = MP
column vector convention
T T T T T T P T = P T M6 M5 M4 M3 M2 M1 T T T T T T M T = M6 M5 M4 M3 M2 M1
P T = P T M T
row vector convention
7
Basic Transformations
Afne transformations: rotate, translate, scale (uniform and non-uniform). x a b c d x y e f g h y = z i j k m z 1 0 0 0 1 1 Translation:
x + tx 1 y + ty 0 = z + tz 0 1 0 0 1 0 0 0 0 1 0 tx x ty y tz z 1 1
8
Basic Transformations
Uniform Scale: Sx x Sx 0 Sy y 0 Sy = Sz z 0 0 1 0 0 Rotations:
x 1 0 y 0 cos = z 0 sin 1 0 0
0 0 Sz 0
1 0 0 x x Sx x 0 y Sy y y 0 1 = = 0 z Sz z z 0 0 1 1 1 1 0 0 S
0 0 1 0
0 x 0 y 0 z 1 1 S
0 sin cos 0
0 x 0 y 0 z 1 1
around x-axis
Basic Transformations
x cos y 0 = z sin 1 0
0 sin 1 0 0 cos 0 0
0 x 0 y 0 z 1 1
around y-axis
x cos y sin = z 0 1 0
sin cos 0 0
0 0 x 0 0 y 1 0 z 0 1 1
around z-axis
Rigid transformations: combinations of translations and rotations, distance and angles are preserved. Only position and orientation in space are changed. Similarity transformations: translation, rotations, uniform scale. Internal angles are not changed.
10
Rotational DOFs are widely used in character animation 3 translational DOFs 48 rotational DOFs
1 DOF: knee
2 DOF: wrist
3 DOF: arm
Composite Transformations
A series of transformations on an object can be applied as a series of matrix multiplications : position in the global coordinate : position in the local coordinate
www.dti.unimi.it/gianini/mfrv07/15_Orientation_Rotations_Quaternions.ppt
12
Representing orientations
What is the best way (most natural and compact) to represent the orientation of an object in space? Which representation is easier to interpolate over time to produce motion? Consider only rigid body transformations. 3x3 rotation matrices Rotation matrices are always square, with real elements. Their rows and columns are orthonormal (unit length and perpendicular to each other). The set of all rotation matrices form a group, known as the rotation group or the special orthogonal group (SO(3)). Very useful for transformation concatenation. Length preserving. What happens under simple linear interpolation?
13
1 0 0
0 0 0 1 0 0
0 0 0
14
Angles used to rotate about xed angles. Any xed triple can be used that doesnt repeat an axis immediately, e.g. x-x-y. Any orientation is then given by three angles, e.g. (10,45,90) Rz(90)Ry(45)Rx(10)
15
Two axes of rotation can line up on top of each other when an object can rotate freely in space (or around a 3 dof joint): gimbal lock. Example: (0,90,0)
16
The representation that will perform an incremental rotation about the x-axis from the (0,90,0) orientation is (90,90+,90). This problem can make interpolation problematic. E.g. interpolation between (0,90,0) and (90,45,90) gives (45,67.5,45) instead of (90,22.5,90) making the object swing out of the y-z plane.
17
E.g. Consider an Euler angle representation that uses x-y-z ordering with angles (,,).
18
19
= Rx ()Ry ()Rz ()
Euler Angles representation is precisely equivalent to xed angle representation in reverse order. Same advantages and disadvantages as xed angle representation: compactness, intuitiveness, gimbal lock.
20
Axis-Angle Representation
Leonhard Euler showed that one orientation can be derived from another by a single rotation about an axis. Any orientation can be represented by three numbers: Two for the axis (longitude, latitude) and one for the angle.
Generally, the axis is represented by a three-dimensional vector and the angle by a scalar. Interpolation between (A1,1) and (A2,2) can be implemented by interpolating the axes of rotation and the angles separately.
21
Axis-angle representation
Interpolating axis-angle representations of (A1,1) and (A2,2) by k to get (Ak,k): Rotate (x,y,z) rotates z around x by y degrees. The axis-angle representation does not lend itself to easily concatenate a series of rotations. No gimbal lock!
22
Quaternions
4-tuples of real numbers w,x,y,z.
w x scalar = w q= y v vector z
q=
cos(/2) sin(/2)r
23
Quaternions
Number system that extends the complex numbers. Described by Sir William R. Hamilton in 1843. Quaternions form a non-commutative group under multiplication. Quaternion multiplication is associative (q1q2)q3 = q1(q2q3) but it is not commutative, q1q2 q2q1. A point in space is represented as [0,v]. Multiplicative identity: [1,(0,0,0)].
K.Shoemake. Animating Rotation with Quaternion Curves. SIGGRAPH ACM TOG Vol. 19, No. 3 1985
24
Multiplication: Two quaternions with zero real parts: cross product of the two vector parts, and a scalar that is their dot product negated.
v1 v2 = [(v1 v2 ), (v1 v2 )]
One quaternion with only a scalar part: multiplication is just real multiplication and vector scaling. Two quaternions with scalar and vector parts:
[w1 , v1 ][w2 , v2 ] = [(w1 w2 v1 v2 ), (w1 v2 + w2 v1 + v1 v2 )]
Except for the cross product this looks like complex multiplication (a1+ib1)(a2+ib2) = (a1a2-b1b2) + i(a1b2 + a2b1) as Hamilton intended.
K.Shoemake. Animating Rotation with Quaternion Curves. SIGGRAPH ACM TOG Vol. 19, No. 3 1985
25
Quaternions multiply with a cross product because rotations confound axes: two rotations around two perpendicular axes can be replaced by a single rotation. In quaternions [0,(0,1,0)] times [0,(0,0,1)] equals [0,(1,0,0)]. The cross product is essential. Quaternion operations give a new orientation in quaternion coordinates.
K.Shoemake. Animating Rotation with Quaternion Curves. SIGGRAPH ACM TOG Vol. 19, No. 3 1985
26
The result will always be a vector with a zero scalar component. The inverse of a quaternion is obtained by negating its vector part and dividing both parts by the magnitude squared.
q
1
1 = [w, v] 2 q
q2 = w2 + v v
Because all effects of magnitude are divided out, any scalar multiple of a quaternion gives the same rotation (like any scalar multiple of a point in homogeneous coordinates gives the same non-homogeneous point).
K.Shoemake. Animating Rotation with Quaternion Curves. SIGGRAPH ACM TOG Vol. 19, No. 3 1985
27
when the magnitude w2 + x2 + y2 + z2 equals 1. The magnitude restriction implies that, plotted in four-dimensional space, these quaternions lie on a sphere of radius one. This sphere of unit quaternions forms a sub-group, S3, of the quaternion group. The spherical metric of S3 is the same as the angular metric of SO(3). From this it follows that we can rotate without speeding up by interpolating on the sphere.
K.Shoemake. Animating Rotation with Quaternion Curves. SIGGRAPH ACM TOG Vol. 19, No. 3 1985
28
K.Shoemake. Animating Rotation with Quaternion Curves. SIGGRAPH ACM TOG Vol. 19, No. 3 1985
29
Exponential maps
Represent an orientation as an axis of rotation and an associated angle of rotation as a single vector. The direction of the vector is the axis of rotation. The magnitude of the vector is the amount of rotation. A zero rotation is assigned to the zero vector, making the representation continuous at the origin. Uses only three parameters (fewer dimensions), no need to re-normalize parameters. This parameterization has well formed derivatives, important when dealing for example with velocities and forces. It has singularities but practically they can be avoided. They do not concatenate well. Free of gimbal lock.
F.S. Grassia. Practical Parameterization of Rotations Using the Exponential Map. The Journal of Graphics Tools. Vol. 3.3 1998.
30
Choose a representation
Interface, user input Euler angles Joint limits Euler angles Interpolate smoothly between sequences of parameter keyframes: Quaternions, Exponential map Compositing: Quaternions, Transformation matrices Computing positions and orientations of points on body parts as functions of the parameters (forward kinematics) Transformation matrices.
F.S. Grassia. Practical Parameterization of Rotations Using the Exponential Map. The Journal of Graphics Tools. Vol. 3.3 1998.
31
Choose a representation
Compute derivatives of the positions and orientations with respect to parameters (Jacobians for inverse kinematics, dynamics and spacetime constraints) Transformation matrices. Integration of ordinary differential equations in parameter space (required by inverse kinematics, dynamics, spacetime constraints) Exponential map.
F.S. Grassia. Practical Parameterization of Rotations Using the Exponential Map. The Journal of Graphics Tools. Vol. 3.3 1998.
32
http://www.euclideanspace.com/maths/geometry/rotations/conversions/index.htm
33