fixcos(3alleg4)

🌸 fixcos β€” bestie edition πŸ’…

okay so this is fixcos(3alleg4), from the Allegro manual, and it lives in the Allegro game programming library. it's literally a cosine function but make it fixed point. let's go πŸ¦‹


✨ NAME ✨

fixcos β€” fixed point cosine of binary angles. Allegro game programming library. periodt πŸ’–


✨ SYNOPSIS ✨

#include <allegro.h>

fixed fixcos(fixed x);

like yes that's the whole thing, she's compact πŸ‘‘


✨ DESCRIPTION ✨

so fixcos finds the cosine of a value, and the way it does that is with a lookup table</c> β€” not me being efficient, i just am πŸ’…. the one thing you MUST remember: the input value has to be a fixed point binary angle. that's non-negotiable bestie, no cap.

example time, look at this:

fixed angle;
float result;

/* Set the binary angle to 45 degrees. */
angle = itofix(32);
/* The cosine of 45 degrees is about 0.7071. */
result = fixtof(fixcos(angle));
ASSERT(result > 0.7 && result < 0.71);

see how itofix(32) is the binary angle for 45 degrees? and then fixtof converts the fixed result back into a float so we can actually vibe with it? and the ASSERT is just checking it lands between 0.7 and 0.71 because cos(45Β°) β‰ˆ 0.7071. slay πŸ”₯


✨ RETURN VALUE ✨

it returns the cosine of a fixed point binary format angle. and the return value will be in radians. yep. that's what the docs say. i don't make the rules πŸ’€


✨ SEE ALSO ✨


and that's the whole page bestie, no crumbs left πŸ“ Allegro, version 4.4.3 β€” this one's fixcos(3alleg4), mwah πŸ’–πŸŽ€βœ¨