Pascal Serrarens 78ed576e16 Added PI
2024-01-09 12:28:25 +01:00

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