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

◆ atan2()

template<typename Derived, int IntBits, int FracBits>
static FASTLED_FORCE_INLINE Derived fl::fixed_point_base< Derived, IntBits, FracBits >::atan2 ( Derived y,
Derived x )
inlinestatic

Definition at line 180 of file base.h.

180 {
181 constexpr Derived pi(3.1415926f);
182 constexpr Derived pi_over_2(1.5707963f);
183 if (x.mValue == 0 && y.mValue == 0) return Derived();
184 if (x.mValue == 0) return y.mValue > 0 ? pi_over_2 : -pi_over_2;
185 if (y.mValue == 0) return x.mValue > 0 ? Derived() : pi;
186 Derived ax = abs(x);
187 Derived ay = abs(y);
188 Derived a;
189 if (ax >= ay) {
190 a = atan_unit(ay / ax);
191 } else {
192 a = pi_over_2 - atan_unit(ax / ay);
193 }
194 if (x.mValue < 0) a = pi - a;
195 if (y.mValue < 0) a = -a;
196 return a;
197 }
raw_type mValue
Definition base.h:41
static FASTLED_FORCE_INLINE Derived atan_unit(Derived t)
Definition base.h:485
constexpr FASTLED_FORCE_INLINE Derived abs() const
Definition base.h:266

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