get_rotation_matrix(3alleg4)

πŸ’« get_rotation_matrix β€” the Allegro manual, bestie edition πŸ’«

okay so this is a page straight out of the Allegro manual, and today we're rotating things in 3D. sit down, grab a snack πŸ“


✨ NAME ✨

get_rotation_matrix, get_rotation_matrix_f β€” they build you X, Y and Z rotation matrices. it's giving Allegro game programming library, and it's giving iconic. πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

void get_rotation_matrix(MATRIX *m, fixed x, fixed y, fixed z);

void get_rotation_matrix_f(MATRIX_f *m, float x, float y, float z);

πŸ¦‹ DESCRIPTION πŸ¦‹

So what this does: it constructs a transformation matrix that rotates points around all three axes by the amounts you pass in. and the amounts are in binary, 256 degrees to a circle format β€” yes bestie, 256, not 360, that's just how we do it here. πŸ’€

Now for the direction of rotation, and this is the part everyone gets confused about, so listen up 🫢. You find it with the right-hand rule: point the dumb of your right hand towards the origin along the axis of rotation, and your fingers will curl in the positive direction of rotation.

E.g. if you rotate around the y axis and look at the scene from above, a positive angle will rotate in clockwise direction. like, actually clockwise, from that viewpoint. no cap. πŸ”₯

lowkey a vibe check on your spatial reasoning, but you got this. ✨

πŸ‘€ SEE ALSO πŸ‘€

go read those too, they're all part of the rotation-adjacent friend group πŸ’œ


and that's the whole page! this was Allegro, version 4.4.3, and honestly? she ate. πŸŽ€ go rotate something, bestie. πŸŒˆβ­πŸ‘‘