8namespace fishnet::math::__impl{
14template<
typename AngleImpl>
18 return static_cast<AngleImpl &
>(*this);
21 const AngleImpl & impl()
const {
22 return static_cast<const AngleImpl &
>(*this);
28 double normalizedAngle(
const double newAngle)
const{
29 return impl().normalizedAngle(newAngle);
32 void setAngle(
const double newAngle){
33 [[unlikely]]
if (std::isnan(newAngle))
34 throw std::invalid_argument(
"NaN cannot be converted to angle!");
35 this->angle = normalizedAngle(newAngle);
38 AbstractAngle() : angle(0.0) {};
42 static AngleImpl asin(
double sine){
43 return AngleImpl::asin(sine);
46 static AngleImpl acos(
double cosine){
47 return AngleImpl::acos(cosine);
50 static AngleImpl atan(
double tangent){
51 return AngleImpl::atan(tangent);
54 static AngleImpl atan2(
double y,
double x){
55 return AngleImpl::atan2(y,x);
58 AngleImpl operator - ()
const {
59 return AngleImpl(-angle);
62 AngleImpl operator + (
const AngleImpl & other)
const {
63 return AngleImpl(angle + other.angle);
66 AngleImpl operator - (
const AngleImpl & other)
const {
67 return AngleImpl(angle - other.angle);
70 AngleImpl & operator+=(
const AngleImpl & other) {
71 setAngle(this->angle + other.angle);
75 AngleImpl & operator-=(
const AngleImpl & other){
76 setAngle(this->angle + other.angle);
80 bool operator>(
const AngleImpl & other)
const {
81 if(*
this == other)
return false;
82 return angle > other.angle;
85 bool operator>=(
const AngleImpl & other)
const {
86 return *
this == other || *
this > other;
89 bool operator==(
const AngleImpl & other)
const {
93 bool operator<=(
const AngleImpl & other)
const {
94 return *
this == other || *
this < other;
97 bool operator< (
const AngleImpl & other)
const {
98 if(*
this == other)
return false;
99 return angle < other.angle;
114 double getAngleValue()
const {
118 size_t hash() const noexcept {
119 return std::hash<double>{}(this->getAngleValue());
Definition NumericConcepts.hpp:4
static constexpr double DOUBLE_EPSILON
Definition Constants.hpp:10