1 / 26

CS 551/645 Fall 2000

CS 551/645 Fall 2000. Parameterized Rotations, Curves, and Surfaces. 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?

kyna
Télécharger la présentation

CS 551/645 Fall 2000

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 551/645Fall 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, q, 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 • (qx, qy, qz) = RzRyRx • Rotate qx degrees about x-axis • Rotate qy degrees about y-axis • Rotate qz 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. Gimbal Lock • 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, q: R(q, n) • 4 degrees of freedom specify 3 rotational degrees of freedom because axis of rotation is constrained to be a unit vector

  11. rperp = r – (n.r) n q V = nx (r – (n.r) n) = nxr Rr rpar = (n.r) n r n Axis-angle Notation Rr = Rrpar + Rrperp = Rrpar + (cos q) rperp + (sin q) V =(n.r) n + cos q(r – (n.r)n) + (sin q) n x r = (cos q)r + (1 – cos q) n (n.r) + (sin q) 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 12 = 1 and i2 = -1 • Quaternion: • Q = a + bi + cj + dk • Where i2 = j2 = k2 = -1 and ij = k and ji = -k • Represented as: q = (s, v) = s + vxi + vyj + vzk

  14. Quaternion • Let q1 = (s1, v1) and q2 = (s2, v2) • q1q2 = (s1s2 – v1.v2, s1v2 + s2v1 + v1 x v2) • Conjugate = q1’ = (s, -v) • q1q1’ = s2 + |v|2 = |q|2 = magnitude • If q has unit magnitude • q = (cosq, sinqn) • q’ = q-1 • Define a pure quaternion: p = (0, r) • Rotating p by q • (0, cos2q r + (1 – cos2q) n (n.r) + sin2qn.r)

  15. Quaternion • Continue to represent quaternion as a 4 DOF vector (as in axis-angle) • But use quaternion algebra: • (cos (q/2), sin(q/2) nx, sin(q/2) ny, sin(q/2) nz) • The product of two unit quaternions is a unit quaternion

  16. Quaternion Example • X-roll of p • (cos (p/2), sin (p/2) (1, 0, 0) = (0, (1, 0, 0)) • Y-roll 0f p • (0, (0, 1, 0) • Z-roll of p • (0, (0, 0, 1)) • Ry (p) followed by Rz (p) • (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/programming/19980703/quaternions_01.htm • Camera control code • http://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) = axt3 + bxt2 + cxt + dx • Similarly for y(t) and z(t) • Let t: (0 <= t <= 1) • Let T = [t3 t2 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 = [3t2 2t 1 0] . C

  24. Continuity of Curves • Two curves that join together • G0, geometric continuity • If direction (but not necessarily magnitude) of tangent matches • G1 geometric continuity • Matching tangent vectors (direction and magnitude) • C1 continuous, first-degree continuity in t (parametric continuity) • Matching direction and magnitude of dn / dtn • Cn 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) = axt3 + bxt2 + cxt + dx • Instead, define curve as weighted combination of 4 well-defined cubic polynomials • Each curve type defines different cubic polynomials and weighting schemes

More Related