fixatan2(3alleg4)
π NAME π
bestie, meet fixatan2 β she's the fixed point version of the libc atan2() routine, and she lives in the Allegro game programming library. manual name? fixatan2(3alleg4), periodt. π
β¨ SYNOPSIS β¨
#include <allegro.h>
fixed fixatan2(fixed y, fixed x);
π DESCRIPTION π
okay so. this is literally just a fixed point version of the libc atan2() routine. no cap.
what she does is compute the arc tangent of y / x, BUT β and this is the iconic part β the signs of both arguments get used to figure out which quadrant the result lands in, and x is allowed to be zero. yes, zero. she said i contain multitudes. π¦
so when would you even need her? when you're converting Cartesian coordinates to polar coordinates. that's the vibe. that's the assignment. that's the whole point. π
example time, and look at this gorgeous thing:
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);
π¨ heads up bestie: that last one fails the assert. like, it's in the example. the assert does not survive. iykyk. π
π RETURN VALUE π
she returns the arc tangent of y / x in fixed point binary format angle, and the range is from -128 to 128. locked in. π₯
but if both x and y are zero? she returns zero and sets errno to EDOM. that's the deal. no drama, just math. π
πΈ SEE ALSO πΈ
(and yeah, the original list opens with a little stray comma. she's quirky like that. we love her.) π
anyway that's the whole page, you ate it, mwah π
this was brought to you by Allegro, version 4.4.3, and the letter fixatan2(3alleg4) β go forth and convert your coordinates, bestie, you've got this π«Άβ¨
π¦ 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