matrix_mul(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

✨ matrix_mul(3) ✨

okay bestie, welcome to the Allegro manual, and specifically to the part where we talk about matrix_mul and matrix_mul_f πŸ’– these two are the matrix-gluing girlies of the Allegro game programming library, and they are literally here to multiply two matrices together. no cap.


πŸŽ€ NAME πŸŽ€

matrix_mul, matrix_mul_f β€” Multiplies two matrices. Allegro game programming library.

like... that's the whole vibe. multiply. matrices. slay. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

void matrix_mul(const MATRIX *m1, const MATRIX *m2, MATRIX *out);

void matrix_mul_f(const MATRIX_f *m1, const MATRIX_f *m2, MATRIX_f *out);

so you pull in <allegro.h> and boom, two icons are available: one for the regular integer-ish MATRIX girlies and one with the _f suffix for the float MATRIX_f girlies 🌸 both take m1 and m2 in, and both drop the answer into out. periodt.


πŸ’« DESCRIPTION πŸ’«

okay so here's the tea β˜• these functions multiply two matrices, and the result goes into out.

heads up bestie: out may be a duplicate of one of the input matrices, but it is faster when the inputs and output are all different. so like, it works if you overlap them, but it's giving "slow queen energy" if you do πŸ™ˆ keep m1, m2 and out all separate if you want the speed.

the resulting matrix will have the same effect as the combination of m1 and m2 β€” meaning when it's applied to a point p:

(p * out) = ((p * m1) * m2)

iconic. so out is literally m1 then m2, stacked into one transformation. and the way that any number of transformations can be concatenated in this way?? obsessed. you can just keep chaining them. πŸ’…

⚠️ IMPORTANT CAVEAT ⚠️ matrix multiplication is not commutative, ie. c matrix_mul(m1, m2) != matrix_mul(m2, m1) so do NOT swap your arguments and expect the same result. order matters, fr fr. flip them and you get a whole different transformation, no cap. 😭

πŸ‘‘ SEE ALSO πŸ‘‘

go read those next bestie, they're part of the same friend group 🫢


and that's the whole page!! this was brought to you by the Allegro girlies, version 4.4.3 ✨ stay multiplying, stay non-commutative, and remember: out can overlap but it's faster when it doesn't πŸ’– bye babes!! πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from