SDL_atan2(3)

πŸ’– SDL_atan2(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the group chat, where today's main character is SDL_atan2 πŸŽ€


✨ NAME ✨

SDL_atan2 β€” compute the arc tangent of y / x, and the way it uses the signs of x and y to adjust the result's quadrant? it's giving precise. πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_stdinc.h>

double SDL_atan2(double y, double x);

✨ DESCRIPTION ✨

so the whole vibe here is: the definition of z = atan2(x, y) is y = x tan(z), where the quadrant of z is determined based on the signs of x and y. no cap, that's the entire personality. πŸ¦‹

Domain: -INF <= x <= INF,

-INF <= y <= INF

Range: -Pi <= y <= Pi

this function operates on double-precision floating point values, so if you're out here needing single-precision floats, use SDL_atan2f instead. and if you just need the arc tangent of one single value, not a whole ratio situation, that's SDL_atan β€” different function, different vibe. 🌸

⚠️ real talk: this function may use a different approximation across different versions, platforms and configurations. i.e, it can return a different value given the same input on different machines or operating systems, or if SDL is updated. so don't be out here expecting bit-for-bit identical results across the whole friend group, okay? πŸ™ˆ

✨ FUNCTION PARAMETERS ✨

  • y β€” floating point value of the numerator (y coordinate). πŸ“
  • x β€” floating point value of the denominator (x coordinate). ⭐

✨ RETURN VALUE ✨

returns arc tangent of y / x in radians β€” OR, if x = 0, then it's either -Pi/2, 0, or Pi/2, depending on the value of y. three possibilities, one of them is yours, good luck bestie πŸ˜­πŸ’–


✨ THREAD SAFETY ✨

it is safe to call this function from any thread. go off, multithreaded icon πŸ‘‘


✨ AVAILABILITY ✨

this function is available since SDL 3.2.0. she's been here a minute πŸ’œ


✨ SEE ALSO ✨


and that's the whole page, periodt πŸŽ€ this was brought to you by Simple Directmedia Layer, serving up SDL 3.4.18, and yeah the footer date lives right here in the sign-off so we're keeping it cute ✨ ily, go compute some quadrants πŸ’–

πŸ“¦ where this page comes from