Computer Graphics Recitation 2. 2 The plan today Learn about rotations in 2D and 3D. Representing rotations by quaternions.

Slides:



Advertisements
Similar presentations
Transformations Ed Angel Professor Emeritus of Computer Science
Advertisements

3D Geometry for Computer Graphics
John C. Hart CS 318 Interactive Computer Graphics
CS B659: Principles of Intelligent Robot Motion Rigid Transformations.
3D Graphics for Game Programming (J. Han) Chapter XI Character Animation.
Chris Hall Aerospace and Ocean Engineering
Computer Graphics Recitation 5.
Linear Algebra and SVD (Some slides adapted from Octavia Camps)
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CS5500 Computer Graphics March 22, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Coordinate-Free Geometry When we learned simple.
3-D Geometry.
3D orientation.
CSCE 689: Computer Animation Rotation Representation and Interpolation
CSCE 441: Computer Graphics Rotation Representation and Interpolation
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.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Rotation representation and Interpolation
Orientations Goal: –Convenient representation of orientation of objects & characters in a scene Applications to: – inverse kinematics –rigid body simulation.
CS 445 / 645 Introduction to Computer Graphics Lecture 21 Representing Rotations Lecture 21 Representing Rotations.
CS I400/B659: Intelligent Robotics Rigid Transformations.
1 Kinematics ( 運動學 ) Primer Jyun-Ming Chen Fall 2009.
Rotations and Translations
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
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)
Mathematical Topics Review of some concepts:  trigonometry  aliasing  coordinate systems  homogeneous coordinates  matrices, quaternions.
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
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.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Computer Graphics Bing-Yu Chen National Taiwan University.
Key Frame Animation and Inverse Kinematics
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.
1 KIPA Game Engine Seminars Jonathan Blow Ajou University December 13, 2002 Day 16.
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
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.
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
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Rotations and Quaternions Week 9, Wed 29 Oct 2003.
3D Kinematics Consists of two parts
Geometric Objects and Transformation
Animating Rotations and Using Quaternions. What We’ll Talk About Animating Translation Animating 2D Rotation Euler Angle representation 3D Angle problems.
Chapter 10 Real Inner Products and Least-Square
CS 551/645 Fall 2000 Parameterized Rotations, Curves, and Surfaces.
CSE Real Time Rendering Week 5. Slides(Some) Courtesy – E. Angel and D. Shreiner.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Math Review.
3D Game Engine Design 1 3D Game Engine Design Ch D MAP LAB.
1 Representation. 2 Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Advanced Math.
Fundamentals of Computer Animation Orientation and Rotation.
Graphics Graphics Korea University kucg.korea.ac.kr Mathematics for Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Computer Animation Algorithms and Techniques
CPSC 641: Computer Graphics Rotation Representation and Interpolation
CS 445 / 645 Introduction to Computer Graphics
3D Kinematics Consists of two parts
COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 TRANSFORMATIONS
Rotation representation and Interpolation
UMBC Graphics for Games
VIRTUAL ENVIRONMENT.
Chapter 2. Geometrical Methods
UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN
Presentation transcript:

Computer Graphics Recitation 2

2 The plan today Learn about rotations in 2D and 3D. Representing rotations by quaternions.

3 Rotation in 2D Rotation about the origin by angle . O  Positive angle means counter-clockwise direction.

4 Rotation in 2D Positive angle means counter-clockwise direction. O  Rotation about the origin by angle .

5 Rotation in 2D – matrix representation Multiply (x, y) by the rotation matrix: O  P (x, y) P’ = R  (P)

6 Interpolating rotations in 2D O  We want to generate N intermediate positions:

7 Interpolating rotations in 2D O  Divide the arc into N pieces of equal length

8 Interpolating rotations in 2D Apply rotations for i = 1, 2, …, N O 

9 Interpolating rotations in 2D Apply rotations for i = 1, 2, …, N O 

10 Interpolating rotations in 2D Apply rotations for i = 1, 2, …, N O 

11 Interpolating rotations in 2D Apply rotations for i = 1, 2, …, N O 

12 Interpolating rotations in 2D Apply rotations for i = 1, 2, …, N O 

13 Interpolating rotations in 2D Apply rotations for i = 1, 2, …, N O 

14 Interpolating rotations in 2D Apply rotations for i = 1, 2, …, N O 

15 Interpolating rotations in 2D Apply rotations for i = 1, 2, …, N O 

16 Rotations mathematically Rotation is a linear orthogonal transformation that doesn’t change the orientation. It means:  Let v, u be vectors (or points), R the rotation = (length and angle preservation) => ||Ru|| = ||u||  In matrix representation: let R be n  n matrix: RR T = I => R -1 = R T det(R) = +1  The rows of R are orthonormal vectors (unit-length pairwise orthogonal vectors). They form a “right-hand” basis of R n.

17 2D rotations as complex numbers multiplication Represent points (x, y) as (x + iy) in C. Multiplying by e i  is equivalent to rotation by angle  : e i  = cos  + i sin  e i  (x + iy) = (cos  + i sin  ) (x + iy) = (x cos   y sin  ) + i (x sin  + y cos  ) O  Re Im P = x + iy P’ = e i  (x + iy)

18 Rotations in 3D

19 Rotations in 3D Euler’s theorem: any orientation can be obtained from a fixed reference orientation by a single unique rotation around an appropriate axis in space.

20 Rotations in 3D We express the rotation in terms of the rotation axis n = (n x, n y, n z ), ||n|| = 1, and the rotation angle . O n  P

21 Rotations in 3D We express the rotation in terms of the rotation axis n = (n x, n y, n z ), ||n|| = 1, and the rotation angle . O n  P P’

22 The formula for P’ Decompose v into to components: v = v || + v   v || = n => v || || n  v  = v – v || => v   n O n P v vv v ||

23 The formula for P’ The rotation doesn’t affect the axis of rotation, therefore: v’ = R n,  (v) = R n,  (v || + v  ) = = R n,  (v || ) + R n,  (v  ) = = v || + R n,  (v  ) We only need to rotate v  by angle  in the plane perpendicular to n. O n P v vv v || P’ v’

24 The formula for P’ O n P vv v ||  The rotation doesn’t affect the axis of rotation, therefore: v’ = R n,  (v) = R n,  (v || + v  ) = = R n,  (v || ) + R n,  (v  ) = = v || + R n,  (v  ) We only need to rotate v  by angle  in the plane perpendicular to n.

25 The formula for P’ We rotate v  in the plane perpendicular to n. The plane = Span{v , n  v  }.  v , n  v   n  n  v   v  Therefore, R n,  (v  ) = cos  v  + sin  (n  v  ) = cos  v  + sin  (n  v) n  v = n  (v || + v  ) = n  v || + n  v  = n  v  n vv v ||  R (v)R (v) vv n  v   R  (v  ) = (cos , sin  )

26 The formula for P’ v’ = R n,  (v) = v || + R n,  (v  ) = = n + cos  v  + sin  (n  v) = = n + cos  (v  n) + + sin  (n  v) = = cos  v + (1  cos  ) n + + sin  (n  v). n vv v ||  P’ R n,  (v) = cos  v + (1  cos  ) n + sin  (n  v).

27 Interpolating rotations in 3D We are animating an object by specifying the key transformations (key frames). Suppose two consecutive key-frames are specified by rotations R 1 and R 2.

28 How to define an interpolation?? We can try to interpolate the two rotation matrices: R(t) = (1  t) R 1 + t R 2 Doesn’t work – the result is not a rotation matrix

29 Solution Use extension of e i  to 3D => quaternions Interpolate the quaternions…

30 Multiplication by e i  in 3D - ??? Hamilton was searching for an extension of complex numbers that would represent 3D rotations. He first tried to find a field of numbers of the form x +yi + zj, where x, y, z  R and i 2 = j 2 =  1. This is not a field (not closed under multiplication). One day, Hamilton realized that he needs four scalars: s +xi + yj + zk ! He called these objects quaternions.

31 Quaternions The ring of quaternions = { s +xi + yj + zk }  i 2 = j 2 = k 2 =  1  ij = k, ji =  k; jk = i, kj =  i; ki = j, ik =  j We will denote q = (s, v) = s +xi + yj + zk where v = (x, y, z) q 1  q 2 = (s 1, v 1 )  (s 2, v 2 ) = = (s 1 s 2 , s 1 v 2 + s 2 v 1 + v 1  v 2 )

32 Conjugate and inner product q = (s 1,  v 1 ) = s  xi  yj  zk = q 1  q 2 = s 1 s 2 + ||q|| 2 = = s 2 + x 2 + y 2 + z 2 q  1 = q / ||q|| 2

33 Rotating with quaternions Represent a vector v as v Q = (0, v). Rotating about axis n, ||n|| = 1, by angle  : R n,  (v) = q  v Q  q q = (cos(  /2), sin(  /2) n) Proof:

34 Some facts about quaternions: Rotating by q and by  q has the same effect. “Rotating” by q such that ||q|| =  has a scaling effect. So, we consider the unit quaternions only ||q|| =1 These quaterions live on the unit sphere in four dimensions… So, we have 3 degrees of freedom for our rotation quaterion (just like with n,  rotation: 1 degree for  + 2 degrees for n = 3 degrees of freedom.)

35 Now, how do we interpolate? Given two rotations q 1 and q 2 Simple interpolation q(t) = (1  t) q 1 +t q 2 is not good enough – doesn’t give “constant speed”: q1q1 q2q2

36 Now, how do we interpolate? Given two rotations q 1 and q 2 Simple interpolation q(t) = (1  t) q 1 +t q 2 is not good enough – doesn’t give “constant speed” The unit quaternions live on the unit sphere, so we want to draw a great arc from q 1 to q 2 on that sphere (it gives the shortest path on the sphere). q1q1 q2q2

37 Spherical interpolation (slerp) q1q1 q2q2 q(t)q(t)

See you next time Next week the lesson will be presented by Andrei, you will learn about SVD…