al_fixcos(3alleg5)

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

✨ al_fixcos β€” Allegro 5 API ✨

okay bestie, welcome to al_fixcos(3alleg5) πŸ’– this one's from the Allegro 5 manual and it's lowkey adorable, it's just a lil trig function, no drama, no cap.


🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

al_fixed al_fixcos(al_fixed x);

like, that's it. that's the whole vibe. πŸ¦‹


πŸŽ€ DESCRIPTION πŸŽ€

so al_fixcos finds the cosine of a value, and the way it does it?? it uses a lookup table πŸ‘‘ no fancy math happening at runtime, just a lil table it peeks at. iconic behaviour honestly.

πŸ’… the input value must be a fixed point binary angle. don't come in here with your regular floats, she will not know what to do with them, fr fr.

here's an example straight from the manual, copy it exactly bestie:

al_fixed angle;
float result;

/* Set the binary angle to 45 degrees. */
angle = al_itofix(32);

/* The cosine of 45 degrees is about 0.7071. */
result = al_fixtof(al_fixcos(angle));
assert(result > 0.7 && result < 0.71);

see how it's giving math but make it ✨fixed point✨? obsessed.


πŸ’œ RETURN VALUE πŸ’œ

she hands you back the cosine of a fixed point binary format angle, returned as a fixed point value. that's the whole deal. 🫢


🌈 reminder bestie: fixed point binary angle in, fixed point value out. iykyk.

so yeah, that's al_fixcos from the Allegro reference manual, living in section 3alleg5. no date on this one, just the manual and the section, and she ate that πŸ’…β­ bye pookie, go draw some circles or whatever πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from