Pascal Serrarens e922a017fa fix == operator
2024-05-12 20:25:19 +02:00

62 lines
1.6 KiB
C++

// 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 {
template <typename T> class AngleOf {
public:
AngleOf(){};
AngleOf(T v) : value(v) {}
operator T() { return value; }
static AngleOf<T> Rad2Deg;
static AngleOf<T> Deg2Rad;
static AngleOf<T> pi;
bool operator==(AngleOf<T> a);
static AngleOf<T> Normalize(AngleOf<T> a);
static AngleOf<T> Clamp(AngleOf<T> a, AngleOf<T> min, AngleOf<T> max);
static AngleOf<T> Difference(AngleOf<T> a, AngleOf<T> b) {
AngleOf<T> r = Normalize(b - a);
return r;
};
static AngleOf<T> MoveTowards(AngleOf<T> fromAngle, AngleOf<T> toAngle,
AngleOf<T> maxAngle);
static AngleOf<T> CosineRuleSide(float a, float b, AngleOf<T> gamma);
static AngleOf<T> CosineRuleAngle(float a, float b, float c);
static AngleOf<T> SineRuleAngle(float a, AngleOf<T> beta, float c);
private:
T value;
};
using Angle = AngleOf<float>;
/*
class Angle {
public:
const static float Rad2Deg;
const static float Deg2Rad;
static float Normalize(float angle);
static float Clamp(float angle, float min, float max);
static float Difference(float a, float b);
static float MoveTowards(float fromAngle, float toAngle, float maxAngle);
static float CosineRuleSide(float a, float b, float gamma);
static float CosineRuleAngle(float a, float b, float c);
static float SineRuleAngle(float a, float beta, float c);
};
*/
} // namespace Passer
using namespace Passer;
#endif