# Visualizing Quaternions

## 1st Edition

**Authors:**Andrew Hanson

**eBook ISBN:**9780080474779

**Hardcover ISBN:**9780120884001

**Paperback ISBN:**9781483299884

**Imprint:**Morgan Kaufmann

**Published Date:**29th December 2005

**Page Count:**530

**View all volumes in this series:**The Morgan Kaufmann Series in Interactive 3D Technology

## Table of Contents

- ABOUT THE AUTHOR
- FOREWORD by Steve Cunningham
- PREFACE
- ACKNOWLEDGMENTS
**PART I ELEMENTS OF QUATERNIONS**- 01 THE DISCOVERY OF QUATERNIONS
- 1.1 Hamilton's Walk
- 1.2 Then Came Octonions
- 1.3 The Quaternion Revival

- 02 FOLKLORE OF ROTATIONS
- 2.1 The Belt Trick
- 2.2 The Rolling Ball
- 2.3 The Apollo 10 Gimbal-lock Incident
- 2.4 3D Game Developer's Nightmare
- 2.5 The Urban Legend of the Upside-down F16
- 2.6 Quaternions to the Rescue

- 03 BASIC NOTATION
- 3.1 Vectors
- 3.2 Length of a Vector
- 3.3 3D Dot Product
- 3.4 3D Cross Product
- 3.5 Unit Vectors
- 3.6 Spheres
- 3.7 Matrices
- 3.8 Complex Numbers

- 04 WHAT ARE QUATERNIONS?
- 05 ROAD MAP TO QUATERNION VISUALIZATION
- 5.1 The Complex Number Connection
- 5.2 The Cornerstones of Quaternion Visualization

- 06 FUNDAMENTALS OF ROTATIONS
- 6.1 2D Rotations
- 6.1.1 Relation to Complex Numbers
- 6.1.2 The Half-angle Form
- 6.1.3 Complex Exponential Version

- 6.2 Quaternions and 3D Rotations
- 6.2.1 Construction
- 6.2.2 Quaternions and Half Angles
- 6.2.3 Double Values

- 6.3 Recovering Θ and
**n** - 6.4 Euler Angles and Quaternions
- 6.5 † Optional Remarks
- 6.5.1 † Connections to Group Theory
- 6.5.2 † "Pure" Quaternion Derivation
- 6.5.3 † Quaternion Exponential Version

- 6.6 Conclusion

- 6.1 2D Rotations
- 07 VISUALIZING ALGEBRAIC STRUCTURE
- 7.1 Algebra of Complex Numbers
- 7.1.1 Complex Numbers
- 7.1.2 Abstract View of Complex Multiplication
- 7.1.3 Restriction to Unit-length Case

- 7.2 Quaternion Algebra
- 7.2.1 The Multiplication Rule
- 7.2.2 Scalar Product
- 7.2.3 Modulus of the Quaternion Product
- 7.2.4 Preservation of the Unit Quaternions

- 7.1 Algebra of Complex Numbers
- 08 VISUALIZING SPHERES
- 8.1 2D: Visualizing an Edge-on Circle
- 8.1.1 Trigonometric Function Method
- 8.1.2 Complex Variable Method
- 8.1.3 Square Root Method

- 8.2 The Square Root Method
- 8.3 3D: Visualizing a Balloon
- 8.3.1 Trigonometric Function Method
- 8.3.2 Square Root Method

- 8.4 4D: Visualizing Quaternion Geometry on
**S**3- 8.4.1 Seeing the Parameters of a Single Quaternion
- 8.4.2 Hemispheres in
**S**3

- 8.1 2D: Visualizing an Edge-on Circle
- 09 VISUALIZING LOGARITHMS AND EXPONENTIALS
- 9.1 Complex Numbers
- 9.2 Quaternions

- 10 VISUALIZING INTERPOLATION METHODS
- 10.1 Basics of Interpolation
- 10.1.1 Interpolation Issues
- 10.1.2 Gram-Schmidt Derivation of the SLERP
- 10.1.3 † Alternative Derivation

- 10.2 Quaternion Interpolation
- 10.3 Equivalent 3×3 Matrix Method

- 10.1 Basics of Interpolation
- 11 LOOKING AT ELEMENTARY QUATERNION FRAMES
- 11.1 A Single Quaternion Frame
- 11.2 Several Isolated Frames
- 11.3 A Rotating Frame Sequence
- 11.4 Synopsis

- 12 QUATERNIONS AND THE BELT TRICK: CONNECTING TO THE IDENTITY
- 12.1 Very Interesting, but Why?
- 12.1.1 The Intuitive Answer
- 12.1.2 † The Technical Answer

- 12.2 The Details
- 12.3 Frame-sequence Visualization Methods
- 12.3.1 One Rotation
- 12.3.2 Two Rotations
- 12.3.3 Synopsis

- 12.1 Very Interesting, but Why?
- 13 QUATERNIONS AND THE ROLLING BALL: EXPLOITING ORDER DEPENDENCE
- 13.1 Order Dependence
- 13.2 The Rolling Ball Controller
- 13.3 Rolling Ball Quaternions
- 13.4 † Commutators
- 13.5 Three Degrees of Freedom From Two

- 14 QUATERNIONS AND GIMBAL LOCK: LIMITING THE AVAILABLE SPACE
- 14.1 Guidance System Suspension
- 14.2 Mathematical Interpolation Singularities
- 14.3 Quaternion Viewpoint

- 01 THE DISCOVERY OF QUATERNIONS
**PART II ADVANCED QUATERNION TOPICS**- 15 ALTERNATIVE WAYS OF WRITING QUATERNIONS
- 15.1 Hamilton's Generalization of Complex Numbers
- 15.2 Pauli Matrices
- 15.3 Other Matrix Forms

- 16 EFFICIENCY AND COMPLEXITY ISSUES
- 16.1 Extracting a Quaternion
- 16.1.1 Positive Trace
**R** - 16.1.2 Nonpositive Trace
**R**

- 16.1.1 Positive Trace
- 16.2 Efficiency of Vector Operations

- 16.1 Extracting a Quaternion
- 17 ADVANCED SPHERE VISUALIZATION
- 17.1 Projective Method
- 17.1.1 The Circle
**S**1 - 17.1.2 General
**S**N Polar Projection

- 17.1.1 The Circle
- 17.2 Distance-preserving Flattening Methods
- 17.2.1 Unroll-and-Flatten
**S**1 - 17.2.2
**S**2 Flattened Equal-area Method - 17.2.3
**S**3 Flattened Equal-volume Method

- 17.2.1 Unroll-and-Flatten

- 17.1 Projective Method
- 18 MORE ON LOGARITHMS AND EXPONENTIALS
- 18.1 2D Rotations
- 18.2 3D Rotations
- 18.3 Using Logarithms for Quaternion Calculus
- 18.4 Quaternion Interpolations Versus Log

- 19 TWO-DIMENSIONAL CURVES
- 19.1 Orientation Frames for 2D Space Curves
- 19.1.1 2D Rotation Matrices
- 19.1.2 The Frame Matrix in 2D
- 19.1.3 Frame Evolution in 2D

- 19.2 What Is a Map?
- 19.3 Tangent and Normal Maps
- 19.4 Square Root Form
- 19.4.1 Frame Evolution in
*(a, b)* - 19.4.2 Simplifying the Frame Equations

- 19.4.1 Frame Evolution in

- 19.1 Orientation Frames for 2D Space Curves
- 20 THREE-DIMENSIONAL CURVES
- 20.1 Introduction to 3D Space Curves
- 20.2 General Curve Framings in 3D
- 20.3 Tubing
- 20.4 Classical Frames
- 20.4.1 Frenet-Serret Frame
- 20.4.2 Parallel Transport Frame
- 20.4.3 Geodesic Reference Frame
- 20.4.4 General Frames

- 20.5 Mapping the Curvature and Torsion
- 20.6 Theory of Quaternion Frames
- 20.6.1 Generic Quaternion Frame Equations
- 20.6.2 Quaternion Frenet Frames
- 20.6.3 Quaternion Parallel Transport Frames

- 20.7 Assigning Smooth Quaternion Frames
- 20.7.1 Assigning Quaternions to Frenet Frames
- 20.7.2 Assigning Quaternions to Parallel Transport Frames

- 20.8 Examples: Torus Knot and Helix Quaternion Frames
- 20.9 Comparison of Quaternion Frame Curve Lengths

- 21 3D SURFACES
- 21.1 Introduction to 3D Surfaces
- 21.1.1 Classical Gauss Map
- 21.1.2 Surface Frame Evolution
- 21.1.3 Examples of Surface Framings

- 21.2 Quaternion Weingarten Equations
- 21.2.1 Quaternion Frame Equations
- 21.2.2 Quaternion Surface Equations (Weingarten Equations)

- 21.3 Quaternion Gauss Map
- 21.4 Example: The Sphere
- 21.4.1 Quaternion Maps of Alternative Sphere Frames
- 21.4.2 Covering the Sphere and the Geodesic Reference Frame South Pole Singularity

- 21.5 Examples: Minimal Surface Quaternion Maps

- 21.1 Introduction to 3D Surfaces
- 22 OPTIMAL QUATERNION FRAMES
- 22.1 Background
- 22.2 Motivation
- 22.3 Methodology
- 22.3.1 The Space of Possible Frames
- 22.3.2 Parallel Transport and Minimal Measure

- 22.4 The Space of Frames
- 22.4.1 Full Space of Curve Frames
- 22.4.2 Full Space of Surface Maps

- 22.5 Choosing Paths in Quaternion Space
- 22.5.1 Optimal Path Choice Strategies
- 22.5.2 General Remarks on Optimization in Quaternion Space

- 22.6 Examples
- 22.6.1 Minimal Quaternion Frames for Space Curves
- 22.6.2 Minimal-quaternion-area Surface Patch Framings

- 23 QUATERNION VOLUMES
- 23.1 Three-degree-of-freedom Orientation Domains
- 23.2 Application to the Shoulder Joint
- 23.3 Data Acquisition and the Double-covering Problem
- 23.3.1 Sequential Data
- 23.3.2 The Sequential Nearest-neighbor Algorithm
- 23.3.3 The Surface-based Nearest-neighbor Algorithm
- 23.3.4 The Volume-based Nearest-neighbor Algorithm

- 23.4 Application Data

- 24 QUATERNION MAPS OF STREAMLINES
- 24.1 Visualization Methods
- 24.1.1 Direct Plot of Quaternion Frame Fields
- 24.1.2 Similarity Measures for Quaternion Frames
- 24.1.3 Exploiting or Ignoring Double Points

- 24.2 3D Flow Data Visualizations
- 24.2.1 AVS Streamline Example
- 24.2.2 Deforming Solid Example

- 24.3 Brushing: Clusters and Inverse Clusters
- 24.4 Advanced Visualization Approaches
- 24.4.1 3D Rotations of Quaternion Displays
- 24.4.2 Probing Quaternion Frames with 4D Light

- 24.1 Visualization Methods
- 25 QUATERNION INTERPOLATION
- 25.1 Concepts of Euclidean Linear Interpolation
- 25.1.1 Constructing Higher-order Polynomial Splines
- 25.1.2 Matching
- 25.1.3 Schlag's Method
- 25.1.4 Control-point Method

- 25.2 The Double Quad
- 25.3 Direct Interpolation of 3D Rotations
- 25.3.1 Relation to Quaternions
- 25.3.2 Method for Arbitrary Origin
- 25.3.3 Exponential Version
- 25.3.4 Special Vector-Vector Case
- 25.3.5 Multiple-level Interpolation Matrices
- 25.3.6 Equivalence of Quaternion and Matrix Forms

- 25.4 Quaternion Splines
- 25.5 Quaternion de Casteljau Splines
- 25.6 Equivalent Anchor Points
- 25.7 Angular Velocity Control
- 25.8 Exponential-map Quaternion Interpolation
- 25.9 Global Minimal Acceleration Method
- 25.9.1 Why a Cubic?
- 25.9.2 Extension to Quaternion Form

- 25.1 Concepts of Euclidean Linear Interpolation
- 26 QUATERNION ROTATOR DYNAMICS
- 26.1 Static Frame
- 26.2 Torque
- 26.3 Quaternion Angular Momentum

- 27 CONCEPTS OF THE ROTATION GROUP
- 27.1 Brief Introduction to Group Representations
- 27.1.1 Complex Versus Real
- 27.1.2 What Is a Representation?

- 27.2 Basic Properties of Spherical Harmonics
- 27.2.1 Representations and Rotation-invariant Properties
- 27.2.2 Properties of Expansion Coefficients Under Rotations

- 27.1 Brief Introduction to Group Representations
- 28 SPHERICAL RIEMANNIAN GEOMETRY
- 28.1 Induced Metric on the Sphere
- 28.2 Induced Metrics of Spheres
- 28.2.1
**S**1 Induced Metrics - 28.2.2
**S**2 Induced Metrics - 28.2.3
**S**3 Induced Metrics - 28.2.4 Toroidal Coordinates on
**S**3 - 28.2.5 Axis-angle Coordinates on
**S**3 - 28.2.6 General Form for the Square-root Induced Metric

- 28.2.1
- 28.3 Elements of Riemannian Geometry
- 28.4 Riemann Curvature of Spheres
- 28.4.1
**S**1 - 28.4.2
**S**2 - 28.4.3
**S**3

- 28.4.1
- 28.5 Geodesics and Parallel Transport on the Sphere
- 28.6 Embedded-vector Viewpoint of the Geodesics

- 15 ALTERNATIVE WAYS OF WRITING QUATERNIONS
**PART III BEYOND QUATERNIONS**- 29 THE RELATIONSHIP OF 4D ROTATIONS TO QUATERNIONS
- 29.1 What Happened in Three Dimensions
- 29.2 Quaternions and Four Dimensions

- 30 QUATERNIONS AND THE FOUR DIVISION ALGEBRAS
- 30.1 Division Algebras
- 30.1.1 The Number Systems with Dimensions 1, 2, 4, and 8
- 30.1.2 Parallelizable Spheres

- 30.2 Relation to Fiber Bundles
- 30.3 Constructing the Hopf Fibrations
- 30.3.1 Real:
**S**0 fiber +**S**1 base =**S**1 bundle - 30.3.2 Complex:
**S**1 fiber +**S**2 base =**S**3 bundle - 30.3.3 Quaternion:
**S**3 fiber +**S**4 base =**S**7 bundle - 30.3.4 Octonion:
**S**7 fiber +**S**8 base =**S**15 bundle

- 30.3.1 Real:

- 30.1 Division Algebras
- 31 CLIFFORD ALGEBRAS
- 31.1 Introduction to Clifford Algebras
- 31.2 Foundations
- 31.2.1 Clifford Algebras and Rotations
- 31.2.2 Higher-dimensional Clifford Algebra Rotations

- 31.3 Examples of Clifford Algebras
- 31.3.1 1D Clifford Algebra
- 31.3.2 2D Clifford Algebra
- 31.3.3 2D Rotations Done Right
- 31.3.4 3D Clifford Algebra
- 31.3.5 Clifford Implementation of 3D Rotations

- 31.4 Higher Dimensions
- 31.5 Pin(
*N*), Spin(*N*), O(*N*), SO(*N*), and All That. . .

- 32 CONCLUSIONS

- 29 THE RELATIONSHIP OF 4D ROTATIONS TO QUATERNIONS
- APPENDICES
- A NOTATION
- A.1 Vectors
- A.2 Length of a Vector
- A.3 Unit Vectors
- A.4 Polar Coordinates
- A.5 Spheres
- A.6 Matrix Transformations
- A.7 Features of Square Matrices
- A.8 Orthogonal Matrices
- A.9 Vector Products
- A.9.1 2D Dot Product
- A.9.2 2D Cross Product
- A.9.3 3D Dot Product
- A.9.4 3D Cross Product

- A.10 Complex Variables

- B 2D COMPLEX FRAMES
- C 3D QUATERNION FRAMES
- C.1 Unit Norm
- C.2 Multiplication Rule
- C.3 Mapping to 3D rotations
- C.4 Rotation Correspondence
- C.5 Quaternion Exponential Form

- D FRAME AND SURFACE EVOLUTION
- D.1 Quaternion Frame Evolution
- D.2 Quaternion Surface Evolution

- E QUATERNION SURVIVAL KIT
- F QUATERNION METHODS
- F.1 Quaternion Logarithms and Exponentials
- F.2 The Quaternion Square Root Trick
- F.3 The
**a**→**b**formula simplified - F.4 Gram-Schmidt Spherical Interpolation
- F.5 Direct Solution for Spherical Interpolation
- F.6 Converting Linear Algebra to Quaternion Algebra
- F.7 Useful Tensor Methods and Identities
- F.7.1 Einstein Summation Convention
- F.7.2 Kronecker Delta
- F.7.3 Levi-Civita Symbol

- G QUATERNION PATH OPTIMIZATION USING SURFACE EVOLVER
- H QUATERNION FRAME INTEGRATION
- I HYPERSPHERICAL GEOMETRY
- I.1 Definitions
- I.2 Metric Properties

- A NOTATION
- REFERENCES
- INDEX

## Description

Introduced 160 years ago as an attempt to generalize complex numbers to higher dimensions, quaternions are now recognized as one of the most important concepts in modern computer graphics. They offer a powerful way to represent rotations and compared to rotation matrices they use less memory, compose faster, and are naturally suited for efficient interpolation of rotations. Despite this, many practitioners have avoided quaternions because of the mathematics used to understand them, hoping that some day a more intuitive description will be available.

The wait is over. Andrew Hanson's new book is a fresh perspective on quaternions. The first part of the book focuses on visualizing quaternions to provide the intuition necessary to use them, and includes many illustrative examples to motivate why they are important—a beautiful introduction to those wanting to explore quaternions unencumbered by their mathematical aspects. The second part covers the all-important advanced applications, including quaternion curves, surfaces, and volumes. Finally, for those wanting the full story of the mathematics behind quaternions, there is a gentle introduction to their four-dimensional nature and to Clifford Algebras, the all-encompassing framework for vectors and quaternions.

## Key Features

- Richly illustrated introduction for the developer, scientist, engineer, or student in computer graphics, visualization, or entertainment computing.
- Covers both non-mathematical and mathematical approaches to quaternions.

## Readership

Programmers and developers in computer graphics and the game industry, scientists and engineers working in aerospace and scientific visualization, students of game development and computer graphics, and those interested in quaternions but who have limited math background.

## Details

- No. of pages:
- 530

- Language:
- English

- Copyright:
- © Morgan Kaufmann 2006

- Published:
- 29th December 2005

- Imprint:
- Morgan Kaufmann

- eBook ISBN:
- 9780080474779

- Hardcover ISBN:
- 9780120884001

- Paperback ISBN:
- 9781483299884

## Reviews

“Almost all computer graphics practitioners have a good grasp of the 3D Cartesian space. However, in many graphics applications, orientations and rotations are equally important, and the concepts and tools related to rotations are less well-known.

Quaternions are the key tool for understanding and manipulating orientations and rotations, and this book does a masterful job of making quaternions accessible. It excels not only in its scholarship, but also provides enough detailed figures and examples to expose the subtleties encountered when using quaternions. This is a book our field has needed for twenty years and I’m thrilled it is finally here.”

—Peter Shirley, Professor, University of Utah

“This book contains all that you would want to know about quaternions, including a great many things that you don’t yet realize that you want to know!”

—Alyn Rockwood, Vice President, ACM SIGGRAPH

“We need to use quaternions any time we have to interpolate orientations, for animating a camera move, simulating a rollercoaster ride, indicating fluid vorticity or displaying a folded protein, and it’s all too easy to do it wrong. This book presents gently but deeply the relationship between orientations in 3D and the differential geometry of the three-sphere in 4D that we all need to understand to be proficient in modern science and engineering, and especially computer graphics.”

—John C. Hart, Associate Professor, Department of Computer Science, University of Illinois Urbana-Champaign, and Editor-in-Chief, *ACM Transactions on Graphics*

“**Visualizing Quaternions** is a comprehensive, yet superbly readable introduction to the concepts, mechanics, geometry, and graphical applications of Hamilton’s lasting contribution to the mathematical description of the real world. To write effectively on this subject, an author has to be a mathematician, physicist and computer scientist; Hanson is all three.

Still, the reader can afford to be much less learned since the patient and detailed explanations makes this book an easy read.”

—George K. Francis, Professor, Mathematics Department, University of Illinois at Urbana-Champaign

“The new book, **Visualizing Quaternions**, will be welcomed by the many fans of Andy Hanson’s SIGGRAPH course.”

—Anselmo Lastra, University of North Carolina at Chapel Hill

“Andy Hanson’s expository yet scholarly book is a stunning tour de force; it is both long overdue, and a splendid surprise! Quaternions have been a perennial source of confusion for the computer graphics community, which sorely needs this book. His enthusiasm for and deep knowledge of the subject shines through his exceptionally clear prose, as he weaves together a story encompassing branches of mathematics from group theory to differential geometry to Fourier analysis. Hanson leads the reader through the thicket of interlocking mathematical frameworks using visualization as the path, providing geometric interpretations of quaternion properties.

The first part of the book features a lucid explanation of how quaternions work that is suitable for a broad audience, covering such fundamental application areas as handling camera trajectories or the rolling ball interaction model. The middle section will inform even a mathematically sophisticated audience, with careful development of the more subtle implications of quaternions that have often been misunderstood, and presentation of less obvious quaternion applications such as visualizing vector field streamlines or the motion envelope of the human shoulder joint. The book concludes with a bridge to the mathematics of higher dimensional analogues to quaternions, namely octonians and Clifford algebra, that is designed to be accessible to computer scientists as well as mathematicians.”

—Tamara Munzner, University of British Columbia

## Ratings and Reviews

## About the Authors

### Andrew Hanson Author

Andrew J. Hanson is a professor of computer science at Indiana University in Bloomington, Indiana, and has taught courses in computer graphics, computer vision, programming languages, and scientific visualization. He received a BA in chemistry and physics from Harvard College and a PhD in theoretical physics from MIT. Before coming to Indiana University, he did research in theoretical physics at the Institute for Advanced Study, Cornell University, the Stanford Linear Accelerator Center, and the Lawrence-Berkeley Laboratory, and then in computer vision at the SRI Artificial Intelligence Center in Menlo Park, CA. He has published a wide variety of technical articles concerning problems in theoretical physics, machine vision, computer graphics, and scientific visualization methods. His current research interests include scientific visualization (with applications in mathematics, cosmology and astrophysics, special and general relativity, and string theory), optimal model selection, machine vision, computer graphics, perception, collaborative methods in virtual reality, and the design of interactive user interfaces for virtual reality and visualization applications.

### Affiliations and Expertise

Indiana University, Bloomington, U.S.A.