fixtan(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– fixtan(3) β€” the Allegro manual, but make it make sense πŸ’–

okay bestie, listen up, we're doing the fixtan page from the Allegro manual and honestly? she's a tiny function with main character energy. she's a (3) page, so she lives in the library section, and she's part of the Allegro game programming library. buckle up, this is short but it eats. πŸ¦‹


✨ NAME ✨

fixtan β€” fixed point tangent of binary angles. yeah. that's the whole name. she said "tangent, but make it fixed point, but also the angles are binary." iconic behavior. πŸ‘‘


🌸 SYNOPSIS 🌸

the way you summon her:

#include <allegro.h>

fixed fixtan(fixed x);

one include, one function, one argument. no drama. slay. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the tea: fixtan finds the tangent of a value using a lookup table. no cap, she's not crunching numbers live, she's just vibing off a table like a girl with a pre-written notes app. πŸ“

and here's the thing you literally cannot forget: the input value must be a fixed point binary angle. not radians, not degrees, not "whatever feels right." binary angle. periodt. 🫢

here's the example, copied exactly because I would never do her dirty like that:

fixed angle, res_a, res_b;
float dif;

angle = itofix(37);
/* Prove that tan(angle) == sin(angle) / cos(angle). */
res_a = fixdiv(fixsin(angle), fixcos(angle));
res_b = fixtan(angle);
dif = fixtof(fixsub(res_a, res_b));
allegro_message("Precision error: %f\n", dif);

so what's happening here? we make an angle with itofix(37), then we prove that tan(angle) == sin(angle) / cos(angle) β€” like, the actual identity, bestie, we're doing math forensics β€” by computing res_a with fixdiv(fixsin(angle), fixcos(angle)) and res_b with fixtan(angle). then we subtract them with fixsub, convert to float with fixtof, and print the difference as the Precision error: %f\n message. because she uses a lookup table, those two aren't gonna match perfectly and the difference is your precision error. it's giving "close enough but not exact," and honestly, same. 😭


πŸ”₯ RETURN VALUE πŸ”₯

she returns the tangent of a fixed point binary format angle. and the return value will be in radians. so like, binary angle in, radians out. a little bilingual moment. we love a polyglot. 🌈


πŸ¦‹ SEE ALSO πŸ¦‹

okay so the original page literally left this section empty β€” no cross-references, nothing, just a heading sitting there all alone. so I'm not gonna invent any, because making stuff up is not the vibe. she's a standalone queen I guess. πŸ’€


just a lil reminder because I love you: that x is a fixed point binary angle, so don't come at her with raw radians and then act surprised. πŸ™ˆ

anyway, that's the whole page!! this was Allegro version 4.4.3, and yeah, she's fixtan(3), the third section, library queen, fixed point icon. go tangent something. mwah. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from