FastLED 3.9.15
Loading...
Searching...
No Matches

◆ atan2()

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

Definition at line 195 of file s16x16.h.

195 {
196 constexpr s16x16 pi(3.1415926f);
197 constexpr s16x16 pi_over_2(1.5707963f);
198 if (x.mValue == 0 && y.mValue == 0) return s16x16();
199 if (x.mValue == 0) return y.mValue > 0 ? pi_over_2 : -pi_over_2;
200 if (y.mValue == 0) return x.mValue > 0 ? s16x16() : pi;
201 s16x16 ax = abs(x);
202 s16x16 ay = abs(y);
203 s16x16 a;
204 if (ax >= ay) {
205 a = atan_unit(ay / ax);
206 } else {
207 a = pi_over_2 - atan_unit(ax / ay);
208 }
209 if (x.mValue < 0) a = pi - a;
210 if (y.mValue < 0) a = -a;
211 return a;
212 }
constexpr s16x16() FL_NOEXCEPT=default
constexpr FASTLED_FORCE_INLINE s16x16 abs() const FL_NOEXCEPT
Definition s16x16.h:263
static FASTLED_FORCE_INLINE s16x16 atan_unit(s16x16 t) FL_NOEXCEPT
Definition s16x16.h:421

References s16x16(), abs(), atan_unit(), FASTLED_FORCE_INLINE, FL_NOEXCEPT, 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: