]> git.tdb.fi Git - libs/math.git/commitdiff
Explicitly convert literals to the T type
authorMikko Rasa <tdb@tdb.fi>
Tue, 5 Sep 2023 10:24:31 +0000 (13:24 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 5 Sep 2023 10:24:31 +0000 (13:24 +0300)
Otherwise MSVC will complain about conversion to float when T is float.

source/geometry/angle.h

index c9d898c007d97d206f6ad878561917242cd1c4b7..c6baf1ac8686fcf7a9bca88fc17f6a3f19f750a9 100644 (file)
@@ -26,16 +26,16 @@ public:
        static Angle from_radians(T);
        static Angle from_turns(T);
 
-       static Angle zero() { return from_radians(0); }
-       static Angle right() { return from_turns(0.25); }
+       static Angle zero() { return from_radians(T(0)); }
+       static Angle right() { return from_turns(T(0.25)); }
        static Angle quarter_turn() { return right(); }
-       static Angle straight() { return from_turns(0.5); }
+       static Angle straight() { return from_turns(T(0.5)); }
        static Angle half_turn() { return straight(); }
-       static Angle full_turn() { return from_turns(1); }
+       static Angle full_turn() { return from_turns(T(1)); }
 
-       T degrees() const { return value*57.2957795130823208768; }
+       T degrees() const { return value*T(57.2957795130823208768); }
        T radians() const { return value; }
-       T turns() const { return value/6.28318530717958647692; }
+       T turns() const { return value/T(6.28318530717958647692); }
 
        Angle &operator+=(Angle);
        Angle &operator-=(Angle);
@@ -155,7 +155,7 @@ inline T operator/(Angle<T> a1, Angle<T> a2)
 template<typename T>
 inline Angle<T> &Angle<T>::wrap_with_base(Angle<T> b)
 {
-       const T two_pi = 6.28318530717958647692;
+       const T two_pi = T(6.28318530717958647692);
        while(value<b.value)
                value += two_pi;
        while(value>=b.value+two_pi)