al_fixatan2(3)
β¨ al_fixatan2(3) β¨
okay bestie, welcome to the Allegro 5 API corner of the universe π this little icon is al_fixatan2, and she's here to do trigonometry for you in fixed point. no floats, no drama, just vibes and angles π
πΈ SYNOPSIS πΈ
#include <allegro5/allegro.h>
al_fixed al_fixatan2(al_fixed y, al_fixed x)
like, that's it. two fixed point numbers in, one angle out. slay π
π¦ DESCRIPTION π¦
so bestie, this is literally the fixed point version of the libc atan2() routine. same energy, but without any of that floating point nonsense π
what she does: computes the arc tangent of y / x. but here's the iconic part β the signs of both arguments get used to determine the quadrant of the result, and x is permitted to be zero. so she's not just blindly dividing, she's actually paying attention to where you are on the plane π iykyk
this function is useful to convert Cartesian coordinates to polar coordinates. literally her whole purpose in life β¨
π Example π
al_fixed result;
/* Sets `result' to binary angle 64. */
result = al_fixatan2(al_itofix(1), 0);
/* Sets `result' to binary angle -109. */
result = al_fixatan2(al_itofix(-1), al_itofix(-2));
/* Fails the assert. */
result = al_fixatan2(0, 0);
assert(!al_get_errno());
look at her go π note that last one β when both are zero she sets errno and the assert fails, which is the whole point of the example. read it carefully bestie, don't come for me π«Ά
π RETURN VALUE π
returns the arc tangent of y / x in fixed point binary format angle, from -128 to 128. that range is not a suggestion, it's the whole map πΊοΈ
but if both x and y are zero? returns zero and sets Allegro's errno to EDOM. that's the error case, no cap π
β οΈ heads up gorgeous β the(0, 0)case is the one that gives youEDOM, so if you're checking for it,al_get_errno()after the call is your bestie π
and that's the tea π this page came from the Allegro reference manual, manual name al_fixatan2(3) β big fan honestly β and the version/date on the tin is the Allegro reference manual, al_fixatan2(3). mwah, go write some polar coordinates, queen ππΈ
π¦ where this page comes from
- arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms