Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

atan2_q12

Function atan2_q12 

Source
pub fn atan2_q12(y: i32, x: i32) -> u16
Expand description

Q0.12 angle of the vector (x, y): the inverse of sin_q12 / cos_q12, so atan2_q12(sin, cos) round-trips an angle.

Octant-linear approximation (exact on the axes and diagonals, worst error about 4° mid-octant): right for facing/steering/aiming logic, not for precision geometry. (0, 0) returns 0. Integer-only; large coordinates are pre-scaled so the math never leaves u32.