matrix_mul(3alleg4)
π matrix_mul β bestie edition π
okay so this is a page from the Allegro manual, and today's main character is matrix_mul (and its float-y twin matrix_mul_f). no cap, it does exactly what it says on the tin: it multiplies two matrices. let's get into it π«Ά
β¨ NAME β¨
matrix_mul, matrix_mul_f β Multiplies two matrices. part of the Allegro game programming library, obviously π
πΈ 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);
π DESCRIPTION π
so basically, bestie, you hand it two matrices and it multiplies them, and it drops the result into out. that's the whole vibe β¨
quick heads up about out though β it's totally allowed to be a duplicate of one of the input matrices, so like, out being the same as m1 or m2? fine, it works, no drama. BUT β and this is the tea β it's faster when the inputs and the output are all different. so if you're chasing that speed, keep them separate, iykyk π«
now the actually iconic part: the resulting matrix has the same effect as the combination of m1 and m2. like, when you apply it to a point p:
(p * out) = ((p * m1) * m2)
so it's giving "do m1, then do m2" but squished into one single matrix. which means you can concatenate any number of transformations this way β stack them, chain them, layer them, it just keeps working. obsessed ππ
β οΈ ok important one, don't skip this: matrix multiplication is NOT commutative. that means matrix_mul(m1, m2) != matrix_mul(m2, m1). order matters, bestie. always has, always will. flip the arguments and you get a different result, periodt. π₯
π SEE ALSO π
and that's the whole page, babe π¦ go forth and multiply (matrices). this was brought to you by Allegro, version 4.4.3 β mwah, take care of her, she's iconic ππ πΈ
π¦ 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