Advanced Computer Graphics Spring 2014

Slides:



Advertisements
Similar presentations
CS B659: Principles of Intelligent Robot Motion Rigid Transformations.
Advertisements

Chris Hall Aerospace and Ocean Engineering
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.
Ch. 2: Rigid Body Motions and Homogeneous Transforms
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
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.
Math for CSLecture 11 Mathematical Methods for Computer Science Lecture 1.
Math for CSLecture 11 Mathematical Methods for Computer Science Lecture 1.
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.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Technical Background.
CS 450: COMPUTER GRAPHICS 3D TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
2IV60 Computer Graphics Basic Math for CG
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.
Mathematical Fundamentals
Rotations and Translations
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Mathematical Topics Review of some concepts:  trigonometry  aliasing  coordinate systems  homogeneous coordinates  matrices, quaternions.
Quaternion and Virtual Trackball CSE 781 Introduction to 3D Image Generation Han-Wei Shen Winter 2007.
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
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.
3D Computer Graphics An oh so brief introduction.
Intro to 3D Models Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Rotations and Translations
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
Rick Parent - CIS681 ORIENTATION Use Quaternions Interpolating rotations is difficult.
1 Fundamentals of Robotics Linking perception to action 2. Motion of Rigid Bodies 南台科技大學電機工程系謝銘原.
Physics Based Modeling
Chapter 2 Rigid Motions and Coordinate Transformations
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.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Rotation and Orientation: Fundamentals Jehee Lee Seoul National University.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 52 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 52 Computer Graphics Three-Dimensional Graphics I.
CSE Real Time Rendering Week 5. Slides(Some) Courtesy – E. Angel and D. Shreiner.
Geometric Transformations
Comparing Two Motions Jehee Lee Seoul National University.
Affine Geometry.
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,
Learning from the Past, Looking to the Future James R. (Jim) Beaty, PhD - NASA Langley Research Center Vehicle Analysis Branch, Systems Analysis & Concepts.
Fundamentals of Computer Animation Orientation and Rotation.
Graphics Graphics Korea University kucg.korea.ac.kr Mathematics for Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
CA 302 Computer Graphics and Visual Programming
Transformations Review 4/18/2018 ©Babu 2009.
Computer Animation Algorithms and Techniques
CPSC 641: Computer Graphics Rotation Representation and Interpolation
CS 445 / 645 Introduction to Computer Graphics
Mobile Robot Kinematics
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
UMBC Graphics for Games
CSE 411 Computer Graphics Lecture #2 Mathematical Foundations
VIRTUAL ENVIRONMENT.
UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN
Rotation and Orientation: Fundamentals
Presentation transcript:

Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

Today’s Topics Quaternions

Geometric Transformations Rotation is defined by an axis and an angle of rotation. Rotation in 3D is not as simple as translation. It can be defined in many ways.

Two Rotational Modalities Definition of Rotational Modality The combination of a definition and a corresponding mathematical representation Two popular modalities Rotation defined by Euler angles represented by general transformation matrices. Rotation defined by Euler’s theorem represented by quaternions.

Euler Angles The space of orientations can be parameterized by Euler angles. A general orientation is written as a series of rotations about three mutually orthogonal axes in space. Usually the x, y, and z axes in a Cartesian coordinate system are used. To describe a general rotation, three Euler angles are required, each of which is the rotation angles about the x, y, and z axes, respectively. The conversion from a general rotation to Euler angles is ambiguous. The same rotation can be obtained with different sets of Euler angles. The resulting rotation depends on the order in which the three rolls are performed.

Rotation Matrices Rotation matrices are the typical choice for implementing Euler angles. For each type of roll, there is a corresponding rotation matrix. The matrices rotate by multiplying them to the position vector for a point in space. The result is the position vector for the rotated point. A rotation matrix is a 3x3 matrix but usually homogeneous 4x4 matrices are used in computer graphics. Matrix multiplication is not generally commutative. It fits well with the fact that rotation in space do not commute.

Quaternions The second rotational modality is rotation defined by Euler’s theorem and implemented with quaternions. Euler’s rotational theorem An arbitrary rotation may be described by only three parameters.

Historical Backgrounds Quaternions were invented by Sir William Rowan Hamilton in 1843. His aim was to generalize complex numbers to three dimensions. Numbers of the form a+ib+jc, where a,b,c are real numbers and i2=j2=-1. He never succeeded in making this generalization. It has later been proven that the set of three-dimensional numbers is not closed under multiplication. Four numbers are needed to describe a rotation followed by a scaling. One number describes the size of the scaling. One number describes the number of degrees to be rotated. Two numbers give the plane in which the vector should be rotated.

Basic Quaternion Mathematics Quaternions, denoted q, consist of a scalar part s and a vector part v=(x,y,z). We will use the following form. Let i2=j2=k2=ijk=-1, ij=k and ji=-k. A quaternion q can be written: q = [s,v] = [s,(x,y,z)] = s+ix+jy+kz. The addition operator, +, is defined

Basic Quaternion Mathematics Multiplication is defined: Quaternion multiplication is not generally commutative. Multiplication by a scalar is defined by rq ≡ [r,0]q Subtraction is defined q – q’ ≡ q + (-1)q’ Let q is a quaternion. Then q* is called the conjugate of q and is defined by q* ≡ [s,v]* ≡ [s, -v].

Basic Quaternion Mathematics Let p,q quaternions. Then (q*)* = q, (pq)* = q*p*, (p+q)* = p* + q*, qq* = q*q The norm of a quaternion q. ||q|| = √qq* The inner product is defined q·q’ = ss’+v·v’ = ss’ + xx’ + yy’ + zz’ Let q,q’ quaternions. Define them as the corresponding four-dimensional vectors and let α be the angle between them. q·q’ = ||q|| ||q’|| cos α .

Basic Quaternion Mathematics The unique neutral element under quaternion multiplication I = [1,0] Inverse under quaternion multiplication qq-1=q-1q=I. q-1=q*/||q||2

Basic Quaternion Mathematics Unit quaternions If ||q|| = 1, then q is called a unit quaternion. Use H1 to denote the set of unit quaternions Let q = [s,v], a unit quaternion. Then, there exists v’ and θ such that q = [cosθ ,v’sinθ ]. Let q, q’ be unit quaternions. Then ||qq’|| = 1 q-1 = q* Etc…

Rotation with Quaternions Let q=[cosθ,nsinθ] be a unit quaternion. Let r = (x,y,z) and p[0,r] be a quaternion. Then p’= qpq-1 is p rotated 2θ about the axis n. Any general three-dimensional rotation about n, |n|=1 can be obtained by a unit quaternion. Choose q such that q=[cosθ/2,nsinθ/2]

Rotation with Quaternions Let q1, q2 be unit quaternions. Rotation by q1 followed by rotation by q2 is equivalent to rotation by q2q1. Geometric intuition

Comparison of Quaternions, Euler Angles and Matrices Euler Angles/Matrices – Disadvantages Lack of intuition The order of rotation axes is important. Gimbal lock It is a concept originating from the air and space industry, where gyroscopes are used. At a certain situation, two rotations act about the same axis. Mathematically gimbal lock corresponds to loosing a degree of freedom in the general rotation matrix.

Comparison of Quaternions, Euler Angles and Matrices Euler Angles/Matrices – Disadvantages Gimbal lock If we letβ=π/2, then a rotation with αwill have the same effect as applying the same rotation with -γ. The rotation only depends on the difference and therefore it has only one degree of freedom. For β=π/2 changes of α and γ result in rotations about the same axis.

Comparison of Quaternions, Euler Angles and Matrices Euler Angles/Matrices – Disadvantages Implementing interpolation is difficult Ambiguous correspondence to rotations The result of composition is not apparent The representation is redundant Euler Angles/Matrices – Advantages The mathematics is well-known and that matrix applications are relatively easy to implement.

Comparison of Quaternions, Euler Angles and Matrices Quaternions – Disadvantages Quaternions only represent rotation Quaternion mathematics appears complicated Quaternions – Advantages Obvious geometrical interpretation Coordinate system independency Simple interpolation methods Compact representation No gimbal lock Simple composition

Example Computation of Quaternion Rotation Question: Rotate a vector (1,0,0) by -90o about (0,1,0). Solution??

Rotational Matrix vs. Unit Quaternion The unit quaternion qR = [q0, q1, q2, q3]t represents rotation around the axis (q1,q2,q3). The rotation matrix R from the unit quaternion is given by

Interpolation of Solid Orientations An application that benefits from a quaternion representation of rotation is keyframe animation. The rotational keyframes must be interpolated to produce reasonable in-between rotations. The quaternion representing the rotations can themselves be interpolated in a natural manner.

Interpolation of Solid Orientations Visualization of interpolation curves Quaternion space is four-dimensional. Direct visualization is impossible. We always interpolate between unit quaternions. The interpolated quaternions will always be unit quaternions. We only need three dimensions to visualize the interpolated curves since they lie on the surface of the unit sphere.

Interpolation of Solid Orientations Interpolation between two rotations Given an arbitrary set M we interpolate between x0∈M and x1∈M parameterized by h∈[0,1]. The resulting interpolation curve γ : MⅹMⅹ [0,1] -> M with γ(x0,x1,0)=x0, γ(x0,x1,1)=x1.

Interpolation of Solid Orientations Linear Euler Interpolations Linear interpolation between two tuples of Euler angles between v0=(x0,y0,z0) and v1=(x1,y1,z1). LinEuler(v0,v1,h) = v0(1-h)+v1h. Not optimal and intuitively correct!!!

Interpolation of Solid Orientations Linear Matrix Interpolations Linear interpolation between rotation matrices – Linear interpolation of every single matrix element independently of the others. LinMat(M0,M1,h) = M0(1-h) + M1h. In general this interpolation method does not produce orthonormal matrices -> Involve translation, scaling, projections etc. -> The interpolation can become wrong.

Interpolation of Solid Orientations Linear Quaternion Interpolations Linear interpolation between rotation quaternions. Lerp(q0,q1,h) = q0(1-h)+q1h. The interpolation curve for linear interpolation gives a straight line in quaternion space. The angular velocity profile is not intuitively correct. Interpolated quaternions may not be unit quaternions.

Interpolation of Solid Orientations Spherical Linear Quaternion Interpolations The same interpolation curve as Lerp method but the interpolation quaternions are unit quaternions. Great arc interpolation on the quaternion unit sphere.

Interpolation of Solid Orientations

3D Registration Problem Statement Input: Two corresponded point sets, pi, xi, where i = 1,…,Np, and Np = Nx. Output: The optimal 3D rotation R and translation vector T so that is minimized.

3D Registration The centers of mass The cross-covariance matrix of both points 4×4 matrix

3D Registration The unit eigenvector (quaternion) qR = [q0, q1, q2, q3]t corresponding to the maximum eigenvalue of the matrix Q(Σpx) is selected as the optimal rotation. The optimal translation vector is given by Rotation matrix R from a unit quaternion

3D Registration

3D Registration Before registration After registration

Virtual Trackball It allows the user to define 3D rotation using mouse in 2D windows. It works similarly like the hardware trackball devices

Virtual Trackball Superimpose a hemi-sphere onto the viewport. This hemi-sphere is projected to a circle inscribed to the viewport. The mouse position in 2D space is projected orthographically to this hemi-sphere.

Virtual Trackball Keep track the previous mouse position and the current position. Calculate their projection positions P1 and P2 to the virtual hemi-sphere. We then rotate the sphere from P1 to P2 by finding the proper rotation axis and angle. This rotation is then applied to the object. You should also remember to accumulate the current rotation to the previous modelview matrix.

Virtual Trackball The axis of rotation is given by the normal to the plane determined by the origin, p1 and p2. The angle between p1 and p2 is given by n = p1  p2 | sin q| =

Virtual Trackball How to calculate P1 and P2? Assuming the mouse position is (x,z), then the sphere point P also has x and z coordinates equal to x and z. Assume the radius of the hemi-sphere is 1. So the y coordinate of P is If a point is outside the circle, project it to the nearest point on the circle. (set y to 0 and renormalize (x,z))

Virtual Trackball Visualization of the algorithm