Quaternion Visualizer
Description
Quaternion Visualizer is a desktop application that enables the visualization of 3D object rotations using various mathematical rotation methods. This application was developed as part of an IRK Lab selection task at ITB, featuring a custom graphics engine built from scratch without relying on external 3D graphics libraries like OpenGL. The program provides an intuitive understanding of how different rotation representations (Quaternion, Euler Angles, and Tait-Bryan Angles) function in 3D space through interactive visualizations.
Features
The Quaternion Visualizer application includes the following key features:
- 3D Object Input (.obj): Allows users to load 3D objects from .obj files.
- Various Rotation Methods: The application supports three main rotation methods:
- Quaternion: Rotations can be applied by specifying an Axis of Rotation (Unit Vector) and an Angle of Rotation (degrees).
- Euler Angles: Rotations can be performed using Euler Angles with multiple convention options.
- Tait-Bryan Angles: Rotations are also supported using Tait-Bryan Angles (X-Y-Z Convention), with inputs for Roll (X), Pitch (Y), and Yaw (Z).
- Comprehensive Visualization:
- 3D Object Visualization: Displays the 3D object both before and after rotation for comparison.
- Axis of Rotation Visualization: Displays the Axis of Rotation as a line (unit vector) for the Quaternion method, or according to the rotation axes for other methods.
- Angle of Rotation Visualization: Displays the Angle of Rotation as a label around the Axis of Rotation.
- Coordinate Axes (XYZ) Visualization: Displays the coordinate axes (X, Y, Z) with clear labels for orientation in 3D space.
- Colored and Labeled Visualization: All visualizations are presented with distinct colors and labels for easy identification.
- Custom Graphics Engine with Camera Control: The application implements its own Graphics Engine to draw 3D objects and other visualizations on a 2D screen. The Camera Control feature allows users to change the screen perspective and viewpoint interactively.
- Reset Object: Allows users to reset the 3D object to its original position and orientation, ensuring a clean state before applying new rotations.
- Animation Option: Rotations can be applied instantly or with a smooth animation for better visual understanding of the transformation process.
Demo Video
Watch a demo of the Quaternion Visualizer in action:

Built With
| Technology | Description |
|---|---|
| Python | Main programming language |
| PyQt5 | Cross-platform GUI framework for desktop application interface |
Quaternion: Explanation and Usage
Quaternions are a number system that extends complex numbers. They were introduced by William Rowan Hamilton in 1843. A quaternion consists of one real part and three imaginary parts, typically represented in the form q=w+xi+yj+zk, where w,x,y,z are real numbers, and i,j,k are imaginary units satisfying the relationships i² = j² = k² = ijk = -1.
Usage
Quaternions are widely used in various fields, especially for representing and calculating rotations in 3D space. Their key advantages make them a preferred choice in applications such as:
- 3D Computer Graphics: Quaternions are fundamental for animating rotations of objects, cameras, and characters, providing smooth and precise movements.
- Computer Vision: They are used in tasks like camera pose estimation and object tracking, where understanding spatial orientation is crucial.
- Robotics: In robotics, quaternions help in controlling the orientation of robotic arms and other components, ensuring accurate positioning and movement.
- Magnetic Resonance Imaging (MRI): Quaternions can be applied in the analysis of spatial data obtained from MRI scans.
- Crystallographic Texture Analysis: They are also employed in analyzing the orientation of crystals within materials.
Euler Angles and Tait-Bryan Angles: Differences
While often used interchangeably, Euler Angles and Tait-Bryan Angles have distinct characteristics:
- Euler Angles: Refer to a sequence of three successive rotations around axes that may be the same. For instance, a rotation sequence like X-Y-X is a valid Euler Angle representation. This general definition is broad and can describe any 3D orientation.
- Tait-Bryan Angles: Are a subset of Euler Angles where the three successive rotations are always performed around different axes. A common example is the Z-Y-X sequence (Yaw-Pitch-Roll), where each rotation is around a unique axis. Tait-Bryan angles are frequently used in aeronautics and robotics due to their intuitive representation of vehicle orientation.
Essentially, all Tait-Bryan Angles are Euler Angles, but not all Euler Angles are Tait-Bryan Angles. The key distinction lies in whether repeated axes are allowed in the rotation sequence.
