FastLED 3.10.8
Loading...
Searching...
No Matches

◆ atan2()

static FASTLED_FORCE_INLINE s16x16 fl::s16x16::atan2 ( s16x16 y,
s16x16 x )
inlinestatic

Definition at line 221 of file s16x16.h.

221 {
222 constexpr s16x16 pi(3.1415926f);
223 constexpr s16x16 pi_over_2(1.5707963f);
224 if (x.mValue == 0 && y.mValue == 0) return s16x16();
225 if (x.mValue == 0) return y.mValue > 0 ? pi_over_2 : -pi_over_2;
226 if (y.mValue == 0) return x.mValue > 0 ? s16x16() : pi;
227 s16x16 ax = abs(x);
228 s16x16 ay = abs(y);
229 s16x16 a;
230 if (ax >= ay) {
231 a = atan_unit(ay / ax);
232 } else {
233 a = pi_over_2 - atan_unit(ax / ay);
234 }
235 if (x.mValue < 0) a = pi - a;
236 if (y.mValue < 0) a = -a;
237 return a;
238 }
static FASTLED_FORCE_INLINE s16x16 atan_unit(s16x16 t) FL_NO_EXCEPT
Definition s16x16.h:465
constexpr FASTLED_FORCE_INLINE s16x16 abs() const FL_NO_EXCEPT
Definition s16x16.h:307
constexpr s16x16() FL_NO_EXCEPT=default

References s16x16(), abs(), atan_unit(), FASTLED_FORCE_INLINE, fl::FL_NO_EXCEPT, fl::x, and fl::y.

Referenced by acos(), and asin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: