Animating Rotations and Using Quaternions. What We’ll Talk About Animating Translation Animating 2D Rotation Euler Angle representation 3D Angle problems.

Slides:



Advertisements
Similar presentations
John C. Hart CS 318 Interactive Computer Graphics
Advertisements

3.3. Introduction to Real-time Physics III
Texture Components and Euler Angles: part 2 13th January 05
CS B659: Principles of Intelligent Robot Motion Rigid Transformations.
3D Kinematics Eric Whitman 1/24/2010. Rigid Body State: 2D p.
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 : “shiv rpi” Linear Algebra A gentle introduction Linear Algebra has become as basic and as applicable.
Chapter 4.1 Mathematical Concepts
Orientation & Quaternions
Computer Graphics Recitation 2. 2 The plan today Learn about rotations in 2D and 3D. Representing rotations by quaternions.
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
3D Coordinate Systems and Transformations Revision 1
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
3-D Geometry.
3D orientation.
Computer Graphics CSC 630 Lecture 2- Linear Algebra.
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.
Rotation representation and Interpolation
Orientations Goal: –Convenient representation of orientation of objects & characters in a scene Applications to: – inverse kinematics –rigid body simulation.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Technical Background.
The linear algebra of Canadarm
CS I400/B659: Intelligent Robotics Rigid Transformations.
Mathematical Fundamentals
Rotations and Translations
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
CS 450: COMPUTER GRAPHICS QUATERNIONS SPRING 2015 DR. MICHAEL J. REALE.
Computer Graphics Bing-Yu Chen National Taiwan University.
Mathematical Foundations Sections A-1 to A-5 Some of the material in these slides may have been adapted from university of Virginia, MIT and Åbo Akademi.
Geometric Transformations Jehee Lee Seoul National University.
Rotations and Translations
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Advanced Computer Graphics Spring 2014
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
What is Kinematics. Kinematics studies the motion of bodies.
January 19, y X Z Translations Objects are usually defined relative to their own coordinate system. We can translate points in space to new positions.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
This Week WeekTopic Week 1 Coordinate Systems, Basic Functions Week 2 Trigonometry and Vectors (Part 1) Week 3 Vectors (Part 2) Week 4 Vectors (Part 3:
Euler Angles This means, that we can represent an orientation with 3 numbers Assuming we limit ourselves to 3 rotations without successive rotations about.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Week 5 - Monday.  What did we talk about last time?  Lines and planes  Trigonometry  Transforms  Affine transforms  Rotation  Scaling  Shearing.
1 Dr. Scott Schaefer Quaternions and Complex Numbers.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Fundamentals of Computer Animation Orientation and Rotation.
Transformations Review 4/18/2018 ©Babu 2009.
Computer Animation Algorithms and Techniques
Review: 3D Transforms Continued
CPSC 641: Computer Graphics Rotation Representation and Interpolation
Geometric Transformations
3D Geometric Transformation
Review: Transformations
3D Transformation.
Translation Rotation Scaling
Review: Transformations
Three-Dimensional Graphics
UMBC Graphics for Games
Three-Dimensional Graphics
A definition we will encounter: Groups
Quaternions are back!!! A global quaternion q is defined as q = q0 + q where q = q1I+ q2 J+ q3K . where q0 is a scalar and q is a vector. A quaternion.
VIRTUAL ENVIRONMENT.
UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN
Presentation transcript:

Animating Rotations and Using Quaternions

What We’ll Talk About Animating Translation Animating 2D Rotation Euler Angle representation 3D Angle problems Quaternions Animating with quaternions

Review: Translation P = X Y Z 1 T = 1 tx 1 ty 1tz 1 P’ = TP =x + tx y + ty z + tz 1 Animation: interpolate over tx,ty,tz in T Move from (10,20,30) to (10,50,40), in time = 0 to 10 ∆x = (50-20)/10 ∆y = (40-30)/ Time = 0 Time = 1Time = 2Time = 10 … Translation 2D Rotation 3D Rotation Euler Problems Quaternions Q. Animation

Review: 2D Rotation 2D Rotation 3D Rotation Euler Problems Quaternions Q. Animation R = cos Ө -sin Ө sin Ө cos Ө 1 P’ = RP Ө Animating 2D Rotations timeRotation Number of frames: 3 ∆R = (90-0)/3 = 30 cos 0 -sin 0 sin 0 cos 0 1 cos 30 -sin 30 sin 30 cos 30 1 cos 60 -sin 60 sin 60 cos 60 1 cos 90 -sin 90 sin 90 cos 90 1

Review: 3D Rotations 3D Rotation Euler Problems Quaternions Q. Animation Rx = 1 cos Ө -sin Ө sin Ө cos Ө 1 Ry = cos Ө sin Ө 1 - sin Ө cos Ө 1 Rz = cos Ө - sin Ө sin Ө cos Ө 1 1 Orientation specified by a combination of rotations in a predetermined order: RxRyRz

Euler Angles Euler’s Theorem: any orientation can be expressed as a single rotation about an axis Can lead to Gimbal lock Gives you the basic idea Euler representation is good basis for calculating quaternions, which work well Ideas: –Orientation represented by an angle and an (x,y,z) vector, e.g. (A 1, Ө 1 ) –Axes represent local coordinate system, not global Rotation order is reverse of global, i.e. RzRyRx Euler Quaternions Q. Animation

Determine axis of rotation from 1st line a to second line b: cross product a x b Determine angle between lines dot product = |a| |b| cos Ø Ø = acos ( a b/ (|a||b|) ) note: normalized angle Animation with k = 0..1 : axis k = rotate(k Ø ) a angle k = (1-k)Ө 1 +kӨ 2 Euler Quaternions Q. Animation Euler Angles Ø Ө1Ө1 Ө2Ө2

Can you do it? Line 1: P1 = (0,1,0) P2 = (1,0,1) Line 2: Q1 = (1,1,1) Q2 = (3,3,3) Cross product: (-4,0,-4) acos ab/|a||b| acos(2/(√3 * 2√3) = acos(1/3) = 70.5 degrees xyz

Motivation We would like to represent 3D rotations about an arbitrary axis We would like to be able to apply a series of arbitrary rotations and have it actually work.. –Direct interpolation of matrices leads to nonsense –Gimbal lock occurs when the axes of two of the three gimbals needed to compensate for rotations in 3D space are driven to the same direction, e.g. (0,90,0) Problems Euler Quaternions Q. Animation

What is a quaternion? Alternative to Euler angles for specifying orientation 4-tuple: use 3 numbers for axis of rotation + 1 for angle of rotation Let q be a quaternion: q = s,v = s, v x, v y, v z = s + v x i + v y j + V z k Quaternions Q. Animation

Quaternion algebra A.i 2 = j 2 = k 2 = -1 = i-j-k B.ij = k = -ji jk = i = -kj ki = j = -ik C.q 1 + q 2 = (s 1 + s 2, v 1 + v 2 ) D.q 1 *q 2 = q 3 if s 1 = s 2 = 0, then q 3 = (v 1 v 2,v 1 x v 2 ) general: q 3 = (s 1 s 2 - v 1 v 2, s 1 v 2 +s 2 v 1 + v 1 x v 2 ) E.q 1 q 2 = (s 1 s 2 + v 1 v 2 ) Quaternions are like complex numbers, with one normal component and 3 imaginary components, i,j,k. (a+bi)(c+di) = (ac-bd) +(cb-ad)i Quaternions Q. Animation

Not all Quaternions Represent Rotations Only unit-length quaternions are rotations || q || = sqrt( s 2 + v v) = 1 q = 1/||q|| [s,v] q -1 = 1/||q|| 2 [s,-v] The inverse rotation is rotation by the same amount by the negative axis Unit quaternion defined by q = (cos Ө/2, sin Ө/2[x,y,z]) Quaternions Q. Animation

Suppose I had an Euler Rotation… 1.q = (cos Ө/2, sin Ө/2[x,y,z]) where Ө and (x,y,z) are the Euler angle and axis respectively 2.Normalize using quaternion normalization rules: q

Note: q = -q = (-s,-v) = cos (-Ө/2), sin(-Ө/2)[-x,-y,-z] = cos (Ө/2), -sin(Ө/2)[-x,-y,-z] =( cos (Ө/2), sin(Ө/2)[x,y,z] ) Quaternions Q. Animation

Convert Q to matrix form M = 1-2y 2 -2z 2 2xy + 2sz 2xy -2sy 2xy + 2sz 1-2x 2 -2z 2 2yz – 2sx 2xz – 2sy 2yz – 2sx 1-2x 2 -2y 2 Quaternions Q. Animation

Rotating a point p by q Rq(p) = q p q where q = [s,-v] (conjugate of q) where p = [0,(p x, p y, p z )] Rq(p) = [s,v][0,p][s,-v] =[0,(s 2 -v v)p + 2v(v p) +2s(v x p)] Quaternions Q. Animation

Consecutive Rotations R 2 (R 1 (p)) q 2 (q 1 p q 1 )q 2 = (q 2 q 1 ) p (q 2 q 1 ) =R 21 (p) Very convenient…

Note about conjugates q = [s,-v] q -1 = 1/|q| 2 q (normalize!!) For unit quaternions, q -1 = q

Animating Rotations Using Quaternions How to find intermediate rotations? A.Linear interpolation: lerp( q 1, q 2, u) = q 1 (1-u) + uq 2 Advantage: easier to find q’ vs. animating rotation matrix Problem: will speed up in the midst of rotation Ө q1q1 q2q2 q: point on a 4D unit sphere

Animating Rotations Using Quaternions B.Spherical Interpolation s lerp( q 1, q 2, u) = [sin(1-u) Ө/sin Ө ] q 1 + [sin uӨ/sin Ө ] q 2 Where q 1 q 2 = cos Ө (note: use smaller Ө ) Why? Plane trigonometry a = b = c sin sin ß sin a b c ß Spherical Trigonometry Same formula, but a,b,c are arc lengths a b c ß