fixasin(3alleg4)

✨ fixasin β€” the inverse sine glow-up ✨

okay so this is a page from the Allegro manual (that's the Allegro game programming library, for anyone new here πŸŽ€), and we're talking about fixasin β€” the fixed point inverse sine lookup table. she's giving trig but make it fixed point πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

fixed fixasin(fixed x);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically fixasin finds the inverse sine of a value, and it does it with a lookup table (iconic, honestly β€” no cap). the input value has to be a fixed point value, that's the whole vibe.

here's the tea though: inverse sine is only defined in the domain from -1 to 1. that's it, that's the range, periodt. if you go outside that input range, the function will set errno to EDOM and return zero. so like, she's not gonna crash on you, she's just gonna say "no <3" via errno 🫢

example time, bestie:

float angle;
fixed val;

/* Sets `val' to a right binary angle (`64'). */
val = fixasin(itofix(1));
/* Sets `angle' to 0.2405. */
angle = fixtof(fixmul(fixasin(ftofix(0.238)), fixtorad_r));
/* This will trigger the assert. */
val = fixasin(ftofix(-1.09));
ASSERT(!errno);

not the last two lines being a little jumpscare 😭 that's the -1.09 out-of-domain situation doing its thing and the assert catching the errno.


πŸ‘‘ RETURN VALUE πŸ‘‘

she returns the inverse sine of a fixed point value, measured as a fixed point binary format angle ✨ or zero if the input was out of range (you know, the EDOM moment). and the important bit: all return values of this function will be in the range -64 to 64. every single one. locked in πŸ”₯


🌈 SEE ALSO 🌈

ngl bestie this section is just empty in the original. nothing here. a whole lot of nothing. so go forth and sine, I guess πŸ’œ

Allegro version 4.4.3 β€” this one's from the fixasin(3alleg4) era, mwah πŸ’– bye bestie, go make some angles πŸ¦‹