CS 445 / 645 Introduction to Computer Graphics

Slides:



Advertisements
Similar presentations
Lecture 3: orientation Computer Animation.
Advertisements

John C. Hart CS 318 Interactive Computer Graphics
CS B659: Principles of Intelligent Robot Motion Rigid Transformations.
Animation Following “Advanced Animation and Rendering Techniques” (chapter 15+16) By Agata Przybyszewska.
3D Kinematics Eric Whitman 1/24/2010. Rigid Body State: 2D p.
Orientation & Quaternions
Computer Graphics Recitation 2. 2 The plan today Learn about rotations in 2D and 3D. Representing rotations by quaternions.
CS5500 Computer Graphics March 22, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Coordinate-Free Geometry When we learned simple.
3D Coordinate Systems and Transformations Revision 1
3D orientation.
CSCE 689: Computer Animation Rotation Representation and Interpolation
CSCE 441: Computer Graphics Rotation Representation and Interpolation
Quaternions CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
CSCE 641: Computer Graphics Rotation Representation and Interpolation Jinxiang Chai.
Transformations. 2 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Coordinate-Free Geometry When we learned simple geometry, most of us.
Rotation representation and Interpolation
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
CS 445 / 645 Introduction to Computer Graphics Lecture 21 Representing Rotations Lecture 21 Representing Rotations.
CS I400/B659: Intelligent Robotics Rigid Transformations.
CS 450: COMPUTER GRAPHICS 3D TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
Computer Vision Group Prof. Daniel Cremers Autonomous Navigation for Flying Robots Lecture 3.1: 3D Geometry Jürgen Sturm Technische Universität München.
1 Kinematics ( 運動學 ) Primer Jyun-Ming Chen Fall 2009.
Visualizing Orientation using Quaternions Gideon Ariel; Rudolf Buijs; Ann Penny; Sun Chung.
Game Mathematics.
Game Physics – Part IV Moving to 3D
3D Kinematics Consists of two parts 3D rotation 3D translation  The same as 2D 3D rotation is more complicated than 2D rotation (restricted to z- axis)
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
CS 450: COMPUTER GRAPHICS QUATERNIONS SPRING 2015 DR. MICHAEL J. REALE.
3D Computer Graphics An oh so brief introduction.
Rotations and Translations
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
1 CS 430/536 Computer Graphics I 3D Transformations World Window to Viewport Transformation Week 2, Lecture 4 David Breen, William Regli and Maxim Peysakhov.
Advanced Computer Graphics Spring 2014
110/27/ :47 Graphics II Animation Introduction and Motion Control Session 6.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Rotations and Quaternions Week 9, Wed 29 Oct 2003.
Rotation and Orientation: Fundamentals Jehee Lee Seoul National University.
CS 551/645 Fall 2000 Parameterized Rotations, Curves, and Surfaces.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 17, 2015 TRANSFORMATIONS AFFINE TRANSFORMATIONS QUATERNIONS.
CS 551/651 Advanced Graphics Technical Background.
Euler Angles This means, that we can represent an orientation with 3 numbers Assuming we limit ourselves to 3 rotations without successive rotations about.
Computer Graphics I, Fall 2010 Transformations.
Week 5 - Monday.  What did we talk about last time?  Lines and planes  Trigonometry  Transforms  Affine transforms  Rotation  Scaling  Shearing.
Introduction to Computer Graphics CS 445 / 645 Lecture 10 Chapter 7: Transformations Gimbal.
Fundamentals of Computer Animation Orientation and Rotation.
REFERENCE: QUATERNIONS/ Ogre Transformations.
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
3D Rotation: more than just a hobby
Transformations Review 4/18/2018 ©Babu 2009.
CS5500 Computer Graphics March 6, 2006.
Computer Animation Algorithms and Techniques
Review: 3D Transforms Continued
CPSC 641: Computer Graphics Rotation Representation and Interpolation
Transformations Objectives
3D Kinematics Consists of two parts
More Rigid Transforms, 3D Rotations
COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 TRANSFORMATIONS
Rotations and Quaternions Week 9, Wed 29 Oct 2003
Translation, Rotation, and Transformation
Rotation representation and Interpolation
Rotation Representations
(c) University of Wisconsin, CS559
UMBC Graphics for Games
CS-378: Game Technology Lecture #2: Transformations Prof. Okan Arikan
Transformations Ed Angel
Geometric Objects and Transformations (II)
Transformations Ed Angel Professor Emeritus of Computer Science
VIRTUAL ENVIRONMENT.
Isaac Gang University of Mary Hardin-Baylor
UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN
Rotation and Orientation: Fundamentals
Presentation transcript:

CS 445 / 645 Introduction to Computer Graphics Lecture 21 Representing Rotations

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)

Representing 3 Rotational DOFs 3x3 Matrix (9 DOFs) Rows of matrix define orthogonal axes 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

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 How would you do it?

Euler Angles (qx, qy, qz) = RzRyRx Axis order is not defined 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

Euler Angles Rotations not uniquely defined Gimbal Lock 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 Remember, the axes stay in the same place during rotations Gimbal Lock Term derived from mechanical problem that arises in gimbal mechanism that supports a compass or a gyro

Gimbal Lock http://www.anticz.com/eularqua.htm

Gimbal Lock Occurs when two axes are aligned 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

A Gimbal Hardware implementation of Euler angles (used for mounting gyroscopes and globes)

Interpolation Interpolation between two Euler angles is not unique ex: (x, y, z) rotation (0, 0, 0) to (180, 0, 0) vs. (0, 0, 0) to (0, 180, 180) Interpolation about different axes are not independent

Interpolation

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

Axis-angle Notation rperp = r – (n.r) n q Rr n q rpar = (n.r) n rperp = r – (n.r) n V = n x (r – (n.r) n) = n x r 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

Axis-angle Rotation Given r – Vector in space to rotate n – Unit-length axis in space about which to rotate q – The amount about n to rotate Solve r’ – The rotated vector r’ r n

Axis-angle Rotation Step 1 Compute rk an extended version of the rotation axis, n rk = (n ¢ r) n rk r’ r

Axis-angle Rotation Compute r? r? = r – (n ¢ r) n r? r’ r

Axis-angle Rotation v q Compute v, a vector perpendicular to rk and r? v = rk £ r? Use v and r? and q to compute r’ v q cos(q) r? + sin(q) v r?

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

Quaternion Remember complex numbers: a + ib Where i2 = -1 Invented by Sir William Hamilton (1843) Remember Hamiltonian path from Discrete II? 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

Quaternion A quaternion is a 4-D unit vector q = [x y z w] It lies on the unit hypersphere x2 + y2 + z2 + w2 = 1 For rotation about (unit) axis v by angle q vector part = (sin q/2) v = [x y z] scalar part = (cos q/2) = w (sin(q/2) nx, sin(q/2) ny, sin(q/2) nz, cos (q/2)) Only a unit quaternion encodes a rotation - normalize

Quaternion Rotation matrix corresponding to a quaternion: [x y z w] = Quaternion Multiplication q1 * q2 = [v1, w1] * [v2, w2] = [(w1v2+w2v1+ (v1 x v2)), w1w2-v1.v2] quaternion * quaternion = quaternion this satisfies requirements for mathematical group Rotating object twice according to two different quaternions is equivalent to one rotation according to product of two quaternions

Quaternion Example X-roll of p Y-roll 0f p Z-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))

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?

SLERP Quaternion is a point on the 4-D unit sphere interpolating rotations requires a unit quaternion at each step another point on the 4-D unit sphere move with constant angular velocity along the great circle between two points Any rotation is defined by 2 quaternions, so pick the shortest SLERP To interpolate more than two points, solve a non-linear variational constrained optimization Ken Shoemake in SIGGRAPH ’85 (www.acm.org/dl)

Quaternion Interpolation Quaternion (white) vs. Euler (black) interpolation Left images are linear interpolation Right images are cubic interpolation

Quaternion Code http://www.gamasutra.com/features/programming/ 19980703/quaternions_01.htm Registration required Camera control code http://www.xmission.com/~nate/smooth.html File, gltb.c gltbMatrix and gltbMotion