Mayavi - Exploring Euler Angles

May 2021

Motivation

As part of my job, I often look at Euler angles that describe rotations in 3D. Since there are many conventions around, its hard to keep an intuition about all of them in mind. To not always just stare at numbers, I want to have a tool that allows to visualize little disturbations of Euler and Tait-Bryan angles*.

Image taken from Wikipedia

Logo from the Mayavi webpage

Also up to this point I was still annoyed to not have found a library that allows to ease creating custom, interactive(!) 3D visualizations in python. I love python to prototype, but neither matplotlib, nor plotly or pyqtgraph provide the right balance to do so.

I want to share my initial experience with the tool that I was looking for: Mavavi.

 

*I will refer to both as Euler angles, a correct distinction can be found on Wikipedia.


Mayavi

For me Mayavi turned out to just be the right tool to prototype and create 3D visualizations and explore the underlying data.

 

Mayavi offers an intuitive script interface that can be used in jupyter notebooks and superb documentation and material to get started. After investing a bit of time, e.g. via the video below, their paper or the website's tutorial, you are ready to get started.

However what makes Mayavi stand-out for me is the way how I as programmer can concentrate on the data. If you are completely new, or just want to get "some sensible" visualization, Mayavi and Traits take care of the rest: the 3D visualization magic, GUI elements to interact with the data and out-of-the-box utilities to export the visualization, e.g. as jpg image.

 

That is not a restriction however, Mayavi also offers help on the next level by providing intuitive highlevel interfaces for common operations on data, such as filtering, colouring & even custom GUI elements. Exactly what I needed.

 

This is not the end. You can go as deep as modifying your 3D Mayavi scene using VTK and build a custom application around it, e.g. using Qt. But to be honest, if I would really want this, I would invest the necessary resources and start my project using VTK and other needed low-level tools directly.


Euler Angles Visualization

To get an intuition for Euler angles I made an application that links graphical representation, angle representation and matrix representation of a rotation.

The angle representation can be manipulated to see the changes in the other two representations.

 

What is displayed?

 

The window containing the graphical representation also displays a world coordinate system as reference. The visualization focuses on the real life labels of the camera and world system labels. Correspondence to the xyz axes is noted in the bottom left corner as legend for the camera system, and world system correspondence is given by the mayavi display system and can be displayed using the "Toggle axes indicator" button in the upper toolbar.

 

The angles convention to be used can be chosen on application start. Accordingly the angles will be listed in the order their corresponding elemental rotation is applied.

 

The convention can be chosen on application start. By default the application launches with the most commonly convention used for aircrafts: Yaw-Pitch-Roll Tait-Bryan angles.

The latest interactive Euler angles Visualization can be found on GitHub.

How can it help?

 

The application allows to enter an Euler angle convention (on application start) and a rotation given by the angles (text field in the GUI) to see how it looks like in a world cordinate system and see the corresponding rotation matrix.

 

Furthermore it allows to apply little disturbations to the angles (sliders in the GUI)  to see how this would act on the rotation entered in the text fields. It helped me to get some intuition when comparing multiple rotations.