al_fixasin(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_fixasin πŸ’–

okay bestie, welcome to the Allegro 5 API corner of the manual, where we do trigonometry but make it fixed-point ✨


🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

al_fixed al_fixasin(al_fixed x);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like. this function hands you the inverse sine of a value, and it does it with a lookup table because we're efficient like that πŸ’…

the input has gotta be a fixed point value, no cap. and here's the tea: inverse sine only exists in the domain from -1 to 1. that's it, that's the whole vibe check. if you feed it anything outside that range, the function sets Allegro's errno to EDOM and returns zero. not a crash, not a guess β€” just a polite little nope πŸ™ˆ

example time, periodt:

float angle;
al_fixed val;

/* Sets `val' to a right binary angle (64). */
val = al_fixasin(al_itofix(1));

/* Sets `angle' to 0.2405. */
angle = al_fixtof(al_fixmul(al_fixasin(al_ftofix(0.238)), al_fixtorad_r));

/* This will trigger the assert. */
val = al_fixasin(al_ftofix(-1.09));
assert(!al_get_errno());

πŸ‘‘ RETURN VALUE πŸ‘‘

it gives you back the inverse sine of that fixed point value, measured as a fixed point binary format angle πŸŽ€ or, if your input was out of range, you get zero instead.

and the range on the way out? every single return value of this function lands between -64 and 64. iconic. consistent. we love a bounded queen ⭐


🫢 quick recap bestie: fixed point in, -1 to 1 only, EDOM + zero if you stray, and the answer always comes home between -64 and 64. iykyk.

this was the Allegro reference manual page for al_fixasin(3alleg5) β€” mwah, go forth and sine responsibly πŸ’œβœ¨

πŸ“¦ where this page comes from