// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0.If a copy of the MPL was not distributed with this // file, You can obtain one at https ://mozilla.org/MPL/2.0/. #ifndef ANGLE_H #define ANGLE_H namespace Passer { namespace LinearAlgebra { static float pi = 3.1415927410125732421875F; static float Rad2Deg = 360.0f / (pi * 2); static float Deg2Rad = (pi * 2) / 360.0f; template class AngleOf { public: AngleOf() {}; AngleOf(int f); AngleOf(float f); // operator float() const; float ToFloat() const; inline T GetBinary() const { return this->value; } static AngleOf Rad2Deg; static AngleOf Deg2Rad; static AngleOf pi; bool operator==(AngleOf a); static AngleOf Normalize(AngleOf a); static AngleOf Clamp(AngleOf a, AngleOf min, AngleOf max); static AngleOf Difference(AngleOf a, AngleOf b) { AngleOf r = Normalize(b.ToFloat() - a.ToFloat()); return r; }; static AngleOf MoveTowards(AngleOf fromAngle, AngleOf toAngle, AngleOf maxAngle); static AngleOf CosineRuleSide(float a, float b, AngleOf gamma); static AngleOf CosineRuleAngle(float a, float b, float c); static AngleOf SineRuleAngle(float a, AngleOf beta, float c); private: T value; }; using Angle = AngleOf; // using Angle = AngleOf; } // namespace LinearAlgebra } // namespace Passer using namespace Passer::LinearAlgebra; #endif