Maths and Technologies for Games Quaternions CO3303 Week 1.

Slides:



Advertisements
Similar presentations
Affine Transformations Jim Van Verth NVIDIA Corporation
Advertisements

Today Composing transformations 3D Transformations
Linear Transformations and Matrices Jim Van Verth Lars M. Bishop
Affine Transformations
3.3. Introduction to Real-time Physics III
3D Kinematics Eric Whitman 1/24/2010. Rigid Body State: 2D p.
Ch. 2: Rigid Body Motions and Homogeneous Transforms
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
CSCE 641: Computer Graphics Rotation Representation and Interpolation Jinxiang Chai.
Rotation representation and Interpolation
Computer Graphics (Fall 2004) COMS 4160, Lecture 3: Transformations 1
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.
Computer Graphics 3D Transformations. 3D Translation Remembering 2D transformations -> 3x3 matrices, take a wild guess what happens to 3D 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 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1
Little Linear Algebra Contents: Linear vector spaces Matrices Special Matrices Matrix & vector Norms.
CS 450: COMPUTER GRAPHICS QUATERNIONS SPRING 2015 DR. MICHAEL J. REALE.
1 KIPA Game Engine Seminars Jonathan Blow Ajou University December 13, 2002 Day 16.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Rotations and Translations
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
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 CO Games Concepts Week 20 Matrices continued Gareth Bellaby.
Maths & Technologies for Games Animation: Practicalities CO3303 Week 3.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Matthew Christian. About Me Introduction to Linear Algebra Vectors Matrices Quaternions Links.
CS 551/645 Fall 2000 Parameterized Rotations, Curves, and Surfaces.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 17, 2015 TRANSFORMATIONS AFFINE TRANSFORMATIONS QUATERNIONS.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Math Review.
Comparing Two Motions Jehee Lee Seoul National University.
Computer Graphics Matrices
3D Game Engine Design 1 3D Game Engine Design Ch D MAP LAB.
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.
III- 1 III 3D Transformation Homogeneous Coordinates The three dimensional point (x, y, z) is represented by the homogeneous coordinate (x, y, z, 1) In.
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.
Notes Over 4.2 Finding the Product of Two Matrices Find the product. If it is not defined, state the reason. To multiply matrices, the number of columns.
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.
REFERENCE: QUATERNIONS/ Ogre Transformations.
Transformations Review 4/18/2018 ©Babu 2009.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
Multiplying Matrices.
Computer Animation Algorithms and Techniques
CPSC 641: Computer Graphics Rotation Representation and Interpolation
Ch. 2: Rigid Body Motions and Homogeneous Transforms
COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 TRANSFORMATIONS
COMP 175: Computer Graphics February 9, 2016
Multiplying Matrices.
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Rotation Representations
(c) University of Wisconsin, CS559
UMBC Graphics for Games
Geometric Objects and Transformations (II)
Multiplying Matrices.
Transformation Operators
UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN
Multiplying Matrices.
Multiplying Matrices.
Multiplying Matrices.
Presentation transcript:

Maths and Technologies for Games Quaternions CO3303 Week 1

We have used two methods to store a rotation: Representing Rotations 2.Three Euler/Fixed angles: – X, Y & Z, (or yaw, pitch & roll) –Can be combined in any order –Used in TL-Engine [See Van Verth for more detail] 1.A matrix: –Can just use 3x3 matrix for rotation –Used these in DirectX

Converting between Formats We can create a matrix from fixed angles –Create a rotation matrix for each angle: –E.g. Z rotation matrix of α: Multiply the matrices together: M = R X *R Y *R Z –Different results for different multiplication orders Can also convert matrix back to fixed angles –See Van Verth or the matrix class in the labs

Euler Angles – Pros/Cons Concise storage – just three floats Euler/Fixed angles seem intuitive –But which order to multiply when forming a matrix? –Different orders in same app can cause problems Are the rotations world or local rotations? –Depends on order again Gimbal lock can occur when one angle is 90° –The other angles interfere with each other, result is ambiguous –E.g. causing strange spinning effects when looking straight up or down (you will have seen this problem in some games)

Matrices – Pros/Cons Unambiguous definition of rotation –As compared to Euler angles 4x4 matrix can also hold position and scale –And totally different things: projection matrix Used by graphics hardware –Must convert all forms to matrices eventually But uses 16 floats –Much processing/storage even for simple operations Can be stored in two ways, by row or by column –APIs (DirectX) and maths texts use different forms

Axis-Angle Rotations Look for other ways to specify rotations… Can specify any rotation as a rotation axis r (a vector) and an angle θ (a scalar): Can convert to and from matrices (see Van Verth or matrix class) Useful way to think about rotation But operations are generally complex with this form –Including interpolation (see later)

Quaternions Quaternions can be used to represent rotation A general quaternion takes the form: –We will use these forms interchangeably We will mostly consider normalised quaternions: However, several quaternion formulae result in un- normalised quaternions –Often need to renormalise quaternions before reuse = examinable

Quaternions A quaternion is a form of axis-angle rotation –When in a normalised form If we rewrite a quaternion in this form: Then r and θ form an axis-angle rotation as described before: –r is a unit vector here

Quaternions – Pros/Cons Why use this more complex variation on angle-axis form? Because quaternions can easily be: –Combined together –Used to transform points/vectors –Quaternions can be interpolated easily A feature vital for animation, which is more difficult with matrices Quaternions only use 4 floats for storage However, they lack hardware support –So we need to convert them to and from matrices

Quaternion Formulae 1 A quaternion can be converted to a matrix: –A little expensive, can be simplified in code –Transposed from Van Verth book for row-based system (DirectX / math text difference) Reverse conversion is also possible (see Van Verth) Quaternions don’t convert easily to Euler angles

Quaternion Formulae 2 Quaternions can be added and scaled: –Scaling is used for normalisation Two quaternions can be multiplied to create a single quaternion performing both rotations: –Same effect as multiplying matrices, order important –Coded efficiently this is faster than matrix multiplication –N.B. Swapped multiplication order from text for row-based system

Quaternion Formulae 3 Inverse of a quaternion (the rotation in the opposite direction) is simple: –Assumes quaternion is normalised –Much faster than matrix equivalent, which can be complex We can also represent vectors as quaternions –Just set w = 0:

Quaternion Formulae 4 Rotate a vertex or vector p by a quaternion q=(w,v) : –Slower than matrix equivalent –1st formula reversed for row-based system (2nd remains same) –N.B. The formula in earlier Van Verth edition is incorrect Derivation of most formulae in Van Verth –As well as further detail

Quaternions: Initial Summary Quaternions can perform similar operations to matrices –With comparable performance –But need to convert to / from matrices –And can’t store position / scaling No compelling reason to use them yet But next week we will see how quaternions compare to matrices for interpolation –And how this is used this for animation