fixatan2(3)
π fixatan2 β the Allegro manual, bestie edition π
okay so you found your way into the Allegro manual, and specifically into fixatan2(3) from the Allegro game programming library. pull up a chair, we're doing trig but make it fixed point. β¨
β¨ NAME β¨
fixatan2 β it's the fixed point version of the libc atan2() routine, living its best life inside the Allegro game programming library. π¦
πΈ SYNOPSIS πΈ
#include <allegro.h>
fixed fixatan2(fixed y, fixed x);
π DESCRIPTION π
So. This is a fixed point version of the libc atan2() routine. No floats invited to this party. π
What it does: it computes the arc tangent of y / x, BUT β and this is the part that eats β the signs of both arguments get used to figure out which quadrant the result should land in, and x is allowed to be zero (no div-by-zero meltdown, we love that for us π«Ά).
It's genuinely useful for converting Cartesian coordinates into polar coordinates. iconic behaviour fr fr.
Example, and yes it's giving tutorial-core:
fixed result;
/* Sets `result' to binary angle 64. */
result = fixatan2(itofix(1), 0);
/* Sets `result' to binary angle -109. */
result = fixatan2(itofix(-1), itofix(-2));
/* Fails the assert. */
result = fixatan2(0, 0);
ASSERT(!errno);
β οΈ not me pointing at that third call βfixatan2(0, 0)setserrno, so thatASSERT(!errno)is going to fail. it says so right there in the comment. periodt. π
π RETURN VALUE π
It returns the arc tangent of y / x as a fixed point binary format angle, ranging from -128 to 128. π
But bestie, listen β if both x and y are zero, it returns zero and sets errno to EDOM. that's the failure vibe check. no cap.
π SEE ALSO π
exlights(3)β go look at it πexspline(3)β also go look at it π
and that's the whole page, bestie!! you ate. ππ
Allegro, version 4.4.3 β signed off with love from fixatan2(3), mwah πβ¨π¦
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms