Quaternions and Euler Angles

Similar documents
Quaternions & Rotation in 3D Space

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

Quaternions and Rotations

12.1 Quaternions and Rotations

ME 597: AUTONOMOUS MOBILE ROBOTICS SECTION 2 COORDINATE TRANSFORMS. Prof. Steven Waslander

Quaternions and Rotations

Quaternions and Rotations

Quaternions and Rotations

CS354 Computer Graphics Rotations and Quaternions

Analysis of Euler Angles in a Simple Two-Axis Gimbals Set

CS612 - Algorithms in Bioinformatics

Orientation & Quaternions

Inertial Measurement Units II!

Quaternion Rotations AUI Course Denbigh Starkey

Autonomous Navigation for Flying Robots

3D Transformations. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 11

CMSC 425: Lecture 6 Affine Transformations and Rotations

Introduction to quaternions. Mathematics. Operations

Transformations: 2D Transforms

Quaternion to Euler Angle Conversion for Arbitrary Rotation Sequence Using Geometric Methods

CS770/870 Spring 2017 Quaternions

3D Kinematics. Consists of two parts

Anatomical Descriptions That Compute Functional Attributes

Rotations in 3D Graphics and the Gimbal Lock

Transformation. Jane Li Assistant Professor Mechanical Engineering & Robotics Engineering

CS184: Using Quaternions to Represent Rotation

Quaternion properties: addition. Introduction to quaternions. Quaternion properties: multiplication. Derivation of multiplication

3D Transformations. CS 4620 Lecture 10. Cornell CS4620 Fall 2014 Lecture Steve Marschner (with previous instructors James/Bala)

1 Historical Notes. Kinematics 5: Quaternions

3D Rotation for Flight Simulator - Google Earth Application R.P. McElrath, October, 2015

Quaternions and Dual Coupled Orthogonal Rotations in Four-Space

Lecture «Robot Dynamics»: Kinematics 2

Vector Calculus: Understanding the Cross Product

+ i a y )( cosφ + isinφ) ( ) + i( a x. cosφ a y. = a x

Visualisation Pipeline : The Virtual Camera

Animating orientation. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

Visual Recognition: Image Formation

Chapter 3 : Computer Animation

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

Rotations (and other transformations) Rotation as rotation matrix. Storage. Apply to vector matrix vector multiply (15 flops)

The Importance of Matrices in the DirectX API. by adding support in the programming language for frequently used calculations.

Rotation and Orientation: Fundamentals. Perelyaev Sergei VARNA, 2011

Geometric Transformations

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

Something noteworthy

Visualizing Quaternions

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

Rotational Joint Limits in Quaternion Space. Gino van den Bergen Dtecta

Coordinate Transformations. Coordinate Transformation. Problem in animation. Coordinate Transformation. Rendering Pipeline $ = $! $ ! $!

PSE Game Physics. Session (3) Springs, Ropes, Linear Momentum and Rotations. Oliver Meister, Roland Wittmann

Lecture Note 3: Rotational Motion

a a= a a =a a 1 =1 Division turned out to be equivalent to multiplication: a b= a b =a 1 b

CS 475 / CS 675 Computer Graphics. Lecture 16 : Interpolation for Animation

Transforms 1 Christian Miller CS Fall 2011

Attitude Representation

IMAGE-BASED RENDERING AND ANIMATION

Section 7.6 Graphs of the Sine and Cosine Functions

Animation. Keyframe animation. CS4620/5620: Lecture 30. Rigid motion: the simplest deformation. Controlling shape for animation

To do this the end effector of the robot must be correctly positioned relative to the work piece.

Animation. Animation

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

Fundamentals of Computer Animation

3D Game Engine Programming. Understanding Quaternions. Helping you build your dream game engine. Posted on June 25, 2012 by Jeremiah van Oosten

Monday, 12 November 12. Matrices

Trigonometric ratios provide relationships between the sides and angles of a right angle triangle. The three most commonly used ratios are:

Secondary Math 3- Honors. 7-4 Inverse Trigonometric Functions

EE 267 Virtual Reality Course Notes: 3-DOF Orientation Tracking with IMUs

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

AH Matrices.notebook November 28, 2016

Computing tilt measurement and tilt-compensated e-compass

Jorg s Graphics Lecture Notes Coordinate Spaces 1

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

Rational Numbers: Graphing: The Coordinate Plane

Math 231E, Lecture 34. Polar Coordinates and Polar Parametric Equations

Transformations Week 9, Lecture 18

Answers. Chapter 2. 1) Give the coordinates of the following points:

Quaternions and Exponentials

Section 6.2 Graphs of the Other Trig Functions

Animation. CS 4620 Lecture 32. Cornell CS4620 Fall Kavita Bala

Animation and Quaternions

Motivation. Parametric Curves (later Surfaces) Outline. Tangents, Normals, Binormals. Arclength. Advanced Computer Graphics (Fall 2010)

METR Robotics Tutorial 2 Week 3: Homogeneous Coordinates SOLUTIONS & COMMENTARY

3D Rotations and Complex Representations. Computer Graphics CMU /15-662, Fall 2017

Representations and Transformations. Objectives

Summer Review for Students Entering Pre-Calculus with Trigonometry. TI-84 Plus Graphing Calculator is required for this course.

Graphics and Interaction Transformation geometry and homogeneous coordinates

Specifying Complex Scenes

Interesting Application. Linear Algebra

Computer Animation II

Computation of Slope

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Lab 2A Finding Position and Interpolation with Quaternions

Vertical Line Test a relationship is a function, if NO vertical line intersects the graph more than once

Reflection (M): Reflect simple plane figures in horizontal or vertical lines;

INF3320 Computer Graphics and Discrete Geometry

Complex Numbers, Polar Equations, and Parametric Equations. Copyright 2017, 2013, 2009 Pearson Education, Inc.

Visualizing Quaternions

ME 115(a): Final Exam (Winter Quarter 2009/2010)

IntroductionToRobotics-Lecture02

CT5510: Computer Graphics. Transformation BOCHANG MOON

Transcription:

Quaternions and Euler Angles Revision #1 This document describes how the VR Audio Kit handles the orientation of the 3D Sound One headset using quaternions and Euler angles, and how to convert between these formalisms. Revision #1 Page 1/8

Table of Contents 1 Description of the 3D Sound One headset...4 Orientation formalisms...4.1 Quaternions...4. Euler angles...5 3 Conversion from quaternions to Euler angles...5 4 Algebra of rotation coordinates and reset heading...6 4.1 Quaternions...6 4. Euler angles...6 5 Application to the HOA library...7 6 Display in OpenGL...7 6.1 Quaternions...7 6. Euler angles...8 Revision #1 Page /8

Document History Date Author Revision Notes Feb 1 st 016 David Le Bansais 1 Initial revision Revision #1 Page 3/8

1 Description of the 3D Sound One headset This headset includes a head-tracking system that knows, in real-time, the position of the user's head in space. This information is available to computers if they connect to the device and request it using Bluetooth. The position of the headset reflects that of the user's head, and is provided as rotations in 3D space. These rotations are relative to the initial position of the headset when it was powered up. This document explains how to interpret the data sent by the headset, for instance to display a headset on the monitor that follows the movements of the user, or to tell the spatialization library how to apply 3D sound effects. Orientation formalisms There are at least two ways to describe orientation in 3D space: Quaternions, a 4-numbers coordinate system that describes orientation as a vector in the x,y,z axis, and an angle θ around this vector. Euler angles, a set of 3 rotations around each of the x,y and z axis. While Euler angles are more intuitive, quaternions are better suited for calculations. For this reason, the headset data is sent as quaternions. It can be converted to Euler angles if desired, and this document explains how to do it..1 Quaternions For a full reference see the Wikipedia article: https://en.wikipedia.org/wiki/quaternions_and_spatial_rotation. The rotation is expressed by a rotation scalar and a vector in 3-dimensional space, the notation used in the rest of this document is the following: Q = q r + q i i + q j j + q k k Q is the quaternion. i, j and k are orthogonal axis in 3D space. The exact direction of i, j and k doesn't matter since they are relative to the position of the headset when it was powered up and therefore have no absolute meaning. q r is the rotation angle, and q i, q j and q k the coefficients along each axis. Note that the vector [q r, q i, q j, q k ] is normalized: q r + q i + q j + q k = 1 The unit quaternion, when there is no rotation, is q r = 1, q i = 0, q j = 0 and q k = 0. Using this notation, the rotation of the headset is expressed as follow: Revision #1 Page 4/8

Left and right (the head rotates on the horizontal plane): q r + q i = 1 and q j = 0, q k = 0. q i becomes positive when the head turns to the right. Up and down (the head rotates on the vertical plane, facing ahead): q r + q k = 1 and q i = 0, q j = 0. q k becomes positive when the head looks down. Rolling (the head is leaning to left and right): q r + q j = 1 and q i = 0, q k = 0. q j becomes positive when the head leans to the left.. Euler angles For a full reference see the Wikipedia article: https://en.wikipedia.org/wiki/euler_angles The VR Audio Kit uses the terms Yaw, Pitch and Roll to describe the rotation of the head following the x-y'-z'' convention, also called intrinsic Tait-Bryan angles. Yaw is the rotation around the vertical axis. The value 0 corresponds to facing the screen (or any reference point), positive values correspond to the head turning to the left, and negative values to the head turning to the right. Pitch is the rotation around the horizontal axis from one ear to the other. The value 0 corresponds to facing the screen (or any reference point), positive values correspond to the head looking down, and negative values to the head looking up. Roll is the rotation around the horizontal axis from the nape to the nose. The value 0 corresponds to the head positioned vertically, positive values correspond to the head leaning to the left, and negative values to the head leaning to the right. The unit triplet when there is no rotation is Yaw = 0, Pitch = 0 and Roll = 0. Euler angles are less suited than quaternions to express all 3D rotations because this coordinate system has singularities, an issue known as gimbal lock. Note that Yaw and q i have different signs: when the head turns to the left, Yaw is positive and q i is negative. 3 Conversion from quaternions to Euler angles Given the choice of axis in the quaternion definition, Euler angles can be obtained using the following formula: Yaw = atan ( (q r q k - q i q j ), 1 (q i + q k )) Pitch = arcsin( (q r q i + q j q k )) Roll = atan ( (q r q j - q i q k ), 1 (q i + q j )) (π / ) The atan (y, x) function computes the arctangent of y/x in such a way that the sign and value of the result are well defined everywhere and follow the quadrant in which (x,y) is located. The complete definition of atan can be found at https://en.wikipedia.org/wiki/atan. Revision #1 Page 5/8

4 Algebra of rotation coordinates and reset heading The rotation of the headset, regardless of the coordinate system used, is relative to the position of the headset when it was powered up. To obtain a meaningful position, applications allow the user to indicate when the headset is in the desired base position (usually when facing a monitor). This operation is called reset heading, and the rotation of the headset when in that position should be the unit rotation: the [1,0,0,0] quaternion or the [0,0,0] Euler angle. For this purpose, an application should record the value of the rotation when the headset is the base position, and substract it from any subsequent measured rotation: R current = R measured R base Calculating the opposite of a rotation, and composing rotations are the two operations we need. 4.1 Quaternions The opposite of the quaternion Q = [q r,q i,q j,q k ] is simply Q' = [q r,-q i,-q j,-q k ]. Composing quaternions Q'' = Q Q' is more complex but simply consists in multiplying the q r + q i i + q j j + q k k and q r ' + q i 'i + q j 'j + q k 'k expressions. Then, equaling coefficients and assuming the products ii, ij obey the following anti-commutation rules: i = j = k = -1 ij = -ji = k jk = -kj = i ki = -ik = j The final result Q'' has the following coefficients: Q r '' = Q r Q r ' Q i Q i ' Q j Q j ' Q k Q k ' Q i '' = Q r Q i ' + Q i Q r ' + Q j Q k ' Q k Q j ' Q j '' = Q r Q j ' Q i Q k ' + Q j Q r ' + Q k Q i ' Q k '' = Q r Q k ' + Q i Q j ' Q j Q i ' + Q k Q r ' 4. Euler angles The opposite of the (Yaw, Pitch, Roll) triplet is (-Yaw,-Pitch, -Roll), and composing Euler angles simply consists in adding their components: Yaw'' = Yaw + Yaw' Pitch'' = Pitch + Pitch' Revision #1 Page 6/8

Roll'' = Roll + Roll' 5 Application to the HOA library The HOA library can be used either with quaternions or Euler angles. We recommend using quaternions when possible because they don't lead to instabilities in calculations, and don't use trigonometric functions. If Q base is the quaternion recorded as the base quaternion when the user chose to reset heading, and if Q last is the last measured quaternion value from the headset, an application should pass the following values to the HOA library mixersetquaternion function: Q r = Q base r Q last r + Q base i Q last i + Q base j Q last j + Q base k Q last k Q i = Q base r Q last i Q base i Q last r Q base j Q last k + Q base k Q last j Q j = Q base r Q last j + Q base i Q last k Q base j Q last r Q base k Q last i Q k = Q base r Q last k Q base i Q last j + Q base j Q last i Q base k Q last r 6 Display in OpenGL Rotations measured from the headset can also be used to display a head (or headset) 3D-model on the screen. In this case it is assumed that the application will use the OpenGL library. This section provides instructions to apply rotations in the OpenGL environment so that the 3D-model display follows the movements of the user's head. 6.1 Quaternions Quaternions are used by converting them into an OpenGL rotation matrix, then multiplying this matrix with the current matrix using the glmultmatrix function. First, a switch of axis and orientation is necessary to make quaternions use the same axis reference as OpenGL: If a, b, c, d are the coefficients to use to create the rotation matrix, we define them as a = q r b = q k c = -q i d = -q j The rotation matrix is then calculated as follow, using the formula found in Wikipedia at https://en.wikipedia.org/wiki/quaternions_and_spatial_rotation#conversion_to_and_from_the_mat rix_representation. The OpenGL matrix is a 4x4 matrix, we therefore extend the formula in Wikipedia from a 3x3 matrix to 4x4 by adding the identity coefficients (they correspond to a null translation), and considering that it is expressed as an array M of 16 values in column-order, it Revision #1 Page 7/8

gives: m 0 = a a + b b - c c d d m 1 = b c + a d m = b d a c m 3 = 0 m 4 = b c a d m 5 = a a - b b + c c d d m 6 = c d + a b m 7 = 0 m 8 = b d + a c m 9 = c d a b m 10 = a a - b b - c c + d d m 11 = 0 m 1 = 0 m 13 = 0 m 14 = 0 m 15 = 1 6. Euler angles These are applied to the OpenGL environment using the glrotate function. To apply a rotation of angle (Yaw, Pitch, Roll) do the following: glrotate(yaw, 0, 1.0, 0) glrotate(pitch, 1.0, 0, 0) glrotate(-roll, 0, 0, 1.0) To apply the opposite of that rotation, calls to glrotate must be reversed: glrotate(roll, 0, 0, 1.0) glrotate(-pitch, 1.0, 0, 0) glrotate(-yaw, 0, 1.0, 0) Revision #1 Page 8/8