exquat(3alleg4)
π exquat β a lil comparison moment between Euler angles and quaternions π
okay bestie, so this is exquat, straight out of the Allegro manual, and it lives in the Allegro game programming library (yes, 3alleg4, the whole vibe). It's not a function, it's an example program, and it's here to show you why one rotation method is lowkey a mess and the other one ate. π¦
β¨ NAME β¨
exquat β a comparison between Euler angles and quaternions. Allegro game programming library.
πΈ SYNOPSIS πΈ
#include <allegro.h>
Example exquat
π DESCRIPTION π
so here's the tea π β Euler angles are convenient for storing and creating 3D orientations. like, genuinely handy. no notes on that part.
BUT. this program is here to demonstrate that they are not good when interpolating between two different orientations. π The problem is solved by using Allegro's quaternion operations. periodt.
In this program, two cubes are rotated between random orientations. Notice that although they have the same beginning and ending orientations, they do not follow the same path between orientations. π
One cube is being rotated by directly incrementing or decrementing the Euler angles from the starting point to the ending point. This is an intuitive notion, but it is incorrect because it does not cause the object to turn around a single unchanging axis of rotation. The axis of rotation wobbles resulting in the object spinning in strange ways. The object will eventually end up in the orientation that the user intended, but it gets there in a way that is unattractive. π Imagine if this method was used to update the position of a camera in a game! Sometimes it would swing wildly and disorient the player. not the camera swinging wildly and disorienting the player bestie, absolutely not. π
The other cube is animated using quaternions. This results in a much more pleasing animation because the cube turns around a single axis of rotation. slay. π
β¨ so basically: Euler angles = the wobbly one, quaternions = the smooth one. same start, same end, completely different journey. iykyk.
π SEE ALSO π
BITMAP(3alleg4)END_OF_MAIN(3alleg4)MATRIX_f(3alleg4)QUAT(3alleg4)acquire_bitmap(3alleg4)allegro_error(3alleg4)allegro_init(3alleg4)allegro_message(3alleg4)apply_matrix_f(3alleg4)blit(3alleg4)circle(3alleg4)clear_keybuf(3alleg4)clear_to_color(3alleg4)create_bitmap(3alleg4)desktop_palette(3alleg4)destroy_bitmap(3alleg4)font(3alleg4)get_camera_matrix_f(3alleg4)get_rotation_matrix(3alleg4)get_rotation_matrix_f(3alleg4)get_rotation_quat(3alleg4)install_keyboard(3alleg4)keypressed(3alleg4)line(3alleg4)matrix_mul_f(3alleg4)palette_color(3alleg4)persp_project_f(3alleg4)quat_interpolate(3alleg4)quat_to_matrix(3alleg4)readkey(3alleg4)release_bitmap(3alleg4)rest(3alleg4)screen(3alleg4)set_gfx_mode(3alleg4)set_palette(3alleg4)set_projection_viewport(3alleg4)textout_ex(3alleg4)
okay that's the whole page bestie, go read those related pages if you wanna go deeper π«Ά
Allegro Β· version 4.4.3 β mwah, that's the version and the whole vibe, tysm for reading, exquat(3alleg4) out. πβ¨
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms