SDL_atan2f(3)

πŸ’– SDL_atan2f(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages, where we make triangles make sense ✨


🌸 NAME 🌸

SDL_atan2f β€” compute the arc tangent of y / x, using the signs of x and y to adjust the result's quadrant. yes babe, it's giving full directional awareness πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_stdinc.h>

float SDL_atan2f(float y, float x);

✨ DESCRIPTION ✨

so here's the vibe. 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. quadrant awareness, we love to see it πŸ¦‹

Domain: -INF <= x <= INF,

-INF <= y <= INF

Range: -Pi <= y <= Pi

this function operates on single-precision floating point values. if you need double-precision floats, use SDL_atan2 instead β€” she's the big sister fr fr πŸ’œ

and if you just wanna calculate the arc tangent of a single value (no division drama, no quadrants), use SDL_atanf. different tool, different slay 🧚

⚠️ heads up bestie: 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 like... don't expect bit-identical results everywhere, okay? no cap. 😭

🫢 FUNCTION PARAMETERS 🫢

  • y β€” floating point value of the numerator (y coordinate).
  • x β€” floating point value of the denominator (x coordinate).

πŸ”₯ RETURN VALUE πŸ”₯

returns the arc tangent of of y / x in radians, or, if x = 0, either -Pi/2, 0, or Pi/2, depending on the value of y. she always knows which way to point πŸ‘‘


πŸ’€ THREAD SAFETY πŸ’€

it is safe to call this function from any thread. go off, concurrent queen ⭐


🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. new-ish but iconic already πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! this came to you from Simple Directmedia Layer, rocking version SDL 3.4.18 β€” mwah, go forth and compute your angles πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from