In this educational project developed for the Computational Geometry class, there are two ways to rotate a 3D object: using Euler angles or using quaternions. In the Euler angles mode, can be shown how the gimbal lock can be achieved and why we should use a quaternion representation.

Currently the project is not complete, because some buttons should be added to show automatically the situations where the gimbal lock take place. It is still possible to manually show the gimbal lock, giving the “right” angle to the rotations.

Also, it should be explained better (and in english) how the input works.

Roles#

This project was entirely made by myself; I designed and developed everything but the airplane 3D model (see below).

  • The project idea was suggested by me to study the application of quaternions for 3D rotations
  • I created the 3 gimbal models
  • I developed the User Interface
  • I wrote all the code

Software#

This software has been developed using Godot 4 and GDScript. The 3D models has been made using Blender.

Source Code#

The source code is available to everyone here and will be updated until the exam is finished.

Inputs and theory#

After the app has been opened, will be possible to move in the 3D environment pressing SHIFT. After this, you can move forward and backwards using W and S. You can move right or left using A and D. You can move up or down using Q and E.

To stop moving around, you can press again SHIFT.

From this mode, you can choose if you want to rotate the object with Euler angles or with quaternions.

If you want to use quaternion rotations, you will need to press a point on the screen; then a line passing from the airplane and the point will be created. After this, will be possible to select the angle you want to rotate the airplane using a *slider+ (if you change the angle, also the applied quaternion will change). Then, you can press the Rotate button and the airplane will rotate by the selected angle using the line that has been created before.

If you want to rotate using Euler angles, you can simply change the 3 sliders and the rotations will update in real-time in relation to the selected axis.

The rotations has been done with a certain order, selecting them from a drop-down menu with an “XYZ” default value: in this case, we rotate first around the X axis, then around the Y axis and finally around the Z axis.

The gimbal lock can be achieved aligning two axis: this can happen if we rotate by -90°/+90° the second axis in the previous defined order (in our example, the Y axis). In this situation can be noticed that rotating the other two axes, we have lose a degree of freedom: rotating around the X axis and around Z axis give the same rotation on the airplane.

When using quaternions, this can’t happen because we are using a single axis to rotate (that can be changed anytime), and there are no pair of axis that can be aligned.

Demo#

Currently, the Windows build can be downloaded from here. No English Translation of the Software is provided, for now. In future versions of the project, the Windows build will be replaced by a WebGL version that will be playable from this website.

Credits#

This work is based on Low Poly Plane by scailman licensed under CC-BY-4.0.

More Projects#