Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 551/645 Fall 2000 Parameterized Rotations, Curves, and Surfaces.

Similar presentations


Presentation on theme: "CS 551/645 Fall 2000 Parameterized Rotations, Curves, and Surfaces."— Presentation transcript:

1 CS 551/645 Fall 2000 Parameterized Rotations, Curves, and Surfaces

2 Administrivia Demo code for assignment 2 is online –Go to assignment 2 page on class web page Test cases for assignment 2 are online –Go to assignment 2 page on class web page gluScaleImage() working? –To keep things simple, use correctly sized textures at first TA is out of town this week – no office hours –Send me mail about questions / camera checkout –Also, Robertson Media Center should have equipment

3 Parameterizing Rotations Straightforward in 2D –A scalar, , represents rotation in plane More complicated in 3D –Three scalars are required to define orientation –Note that three scalars are also required to define position –Objects free to translate and tumble in 3D have 6 degrees of freedom (DOF)

4 Representing 3 Rotational DOFs Euler Angles (3 DOFs) –Rot x + Rot y + Rot z Axis-angle (4 DOFs) –Axis of rotation + Rotation amount Quaternion (4 DOFs) –4 dimensional complex numbers 3x3 Matrix (9 DOFs) –Rows of matrix define orthogonal axes

5 Euler Angles (  x,  y,  z ) = R z R y R x –Rotate  x degrees about x-axis –Rotate  y degrees about y-axis –Rotate  z degrees about z-axis Axis order is not defined –(y, z, x), (x, z, y), (z, y, x)… are all legal –Pick one

6 Euler Angles Rotations not uniquely defined –ex: (z, x, y) = (90, 45, 45) = (45, 0, -45) takes positive x-axis to (1, 1, 1) –cartesian coordinates are independent of one another, but Euler angles are not Gimbal Lock –Term derived from mechanical problem that arises in gimbal mechanism that supports a compass or a gyro

7 Gimbal Lock

8 Occurs when two axes are aligned Euler angles do not rotate the coordinate axes But, second and third rotations have effect of transforming earlier rotations –ex: Rot x, Rot y, Rot z If Rot y = 90 degrees, Rot z == -Rot x

9 Interpolation Interpolation between two Euler angles is not unique ex: (x, y, z) rotation order –from (0, 0, 0) to (180, 0, 0) –from (0, 0, 0) to (0, 180, 180) –interpolating each axis of rotation idependently results in different animation sequences

10 Axis-angle Notation Define an axis of rotation (x, y, z) and a rotation about that axis,  R( , n) 4 degrees of freedom specify 3 rotational degrees of freedom because axis of rotation is constrained to be a unit vector

11 Axis-angle Notation r RrRr n  r par = (n.r) n r perp = r – (n.r) n V = n x (r – (n.r) n) = n x r Rr = Rr par + Rr perp = Rr par + (cos  ) r perp + (sin  ) V =(n.r) n + cos  (r – (n.r)n) + (sin  ) n x r = (cos  )r + (1 – cos  ) n (n.r) + (sin  ) n x r

12 Axis-angle Notation No easy way to determine how to concatenate many axis-angle rotations that result in final desired axis-angle rotation No simple way to interpolate rotations

13 Quaternion Remember complex numbers: a + ib –Where 1 2 = 1 and i 2 = -1 Quaternion: –Q = a + bi + cj + dk Where i 2 = j 2 = k 2 = -1 and ij = k and ji = -k –Represented as: q = (s, v) = s + v x i + v y j + v z k

14 Quaternion Let q 1 = (s 1, v 1 ) and q 2 = (s 2, v 2 ) –q 1 q 2 = (s 1 s 2 – v 1.v 2, s 1 v 2 + s 2 v 1 + v 1 x v 2 ) –Conjugate = q 1 ’ = (s, -v) –q 1 q 1 ’ = s 2 + |v| 2 = |q| 2 = magnitude If q has unit magnitude –q = (cos , sin  n) –q’ = q -1 –Define a pure quaternion: p = (0, r) –Rotating p by q (0, cos2  r + (1 – cos2  ) n (n.r) + sin2  n.r)

15 Quaternion Continue to represent quaternion as a 4 DOF vector (as in axis-angle) But use quaternion algebra: –(cos (  /2), sin(  /2) n x, sin(  /2) n y, sin(  /2) n z ) The product of two unit quaternions is a unit quaternion

16 Quaternion Example X-roll of  –(cos (  /2), sin (  /2) (1, 0, 0) = (0, (1, 0, 0)) Y-roll 0f  –(0, (0, 1, 0) Z-roll of  –(0, (0, 0, 1)) R y (  ) followed by R z (  ) –(0, (0, 1, 0) times (0, (0, 0, 1)) = (0, (0, 1, 0) x (0, 0, 1) = (0, (1, 0, 0))

17 Quaternion Interpolation Biggest advantage of quaternions –Interpolation –Cannot linearly interpolate between two quaternions because it would speed up in middle –Instead, Spherical Linear Interpolation, slerp() –Used by modern video games for third-person perspective –Why?

18 Quaternion Code http://www.gamasutra.com/features/progra mming/19980703/quaternions_01.htmhttp://www.gamasutra.com/features/progra mming/19980703/quaternions_01.htm Camera control code –http://www.xmission.com/~nate/smooth.htmlhttp://www.xmission.com/~nate/smooth.html File, gltb.c gltbMatrix and gltbMotion

19 Using Quaternions in Assignment 3 part 2 Nate’s ‘Smooth’ program uses axis-angle to represent the rotation He then uses glRotate to convert this to a rotation matrix and adds it to the modelview matrix stack Instead, you convert axis-angle to quaternion and then to rotation matrix You then put this rotation matrix on stack

20 Rotation Matrix 9 DOFs must reduce to 3 Rows must be unit length (-3 DOFs) Rows must be orthogonal (-3 DOFs) Drifting matrices is very bad –Numerical errors results when trying to gradually rotate matrix by adding derivatives –Resulting matrix may scale / shear –Gram-Schmidt algorithm will re-orthogonalize your matrix Difficult to interpolate between matrices

21 Representations of Curves Problems with series of points used to model a curve –Piecewise linear - Does not accurately model a smooth line –It’s tedious –Expensive to manipulate curve because all points must be repositioned Instead, model curve as piecewise-polynomial –x = x(t), y = y(t), z = z(t) where x(), y(), z() are polynomials

22 Cubic Polynomials x(t) = a x t 3 + b x t 2 + c x t + d x –Similarly for y(t) and z(t) Let t: (0 <= t <= 1) Let T = [t 3 t 2 t 1] Coefficient Matrix C Curve: Q(t) = T.C

23 Parametric Curves Derivative of Q(t) is the tangent vector at t: –d/dt Q(t) = Q’(t) = d/dt T. C = [3t 2 2t 1 0]. C

24 Continuity of Curves Two curves that join together –G 0, geometric continuity If direction (but not necessarily magnitude) of tangent matches –G 1 geometric continuity Matching tangent vectors (direction and magnitude) –C 1 continuous, first-degree continuity in t (parametric continuity) Matching direction and magnitude of d n / dt n C n continous

25 Parametric Curves Hermite – two endpoints and two endpoint tangent vectors Bezier - two endpoints and two other points that define the endpoint tangent vectors Splines – four control points. –C1 and C2 continuity at the join points –Come close to their control points, but not guaranteed to touch them

26 Parametric Curves Difficult to conceptualize curve as –x(t) = a x t 3 + b x t 2 + c x t + d x Instead, define curve as weighted combination of 4 well-defined cubic polynomials Each curve type defines different cubic polynomials and weighting schemes


Download ppt "CS 551/645 Fall 2000 Parameterized Rotations, Curves, and Surfaces."

Similar presentations


Ads by Google