fixtan(3)
π 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
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms