// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "tdm/Types.h" #include "tdm/Transforms.h" #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4365 4987) #endif #include #ifdef _MSC_VER #pragma warning(pop) #endif namespace tdm { #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4521) #endif template struct ang { using value_type = T; value_type value; ang() : value{} { } explicit constexpr ang(value_type val) : value{val} { } constexpr ang(const ang& other) : value{other.value} { } ang& operator=(const ang& other) { value = other.value; return *this; } template::value>::type* = nullptr> explicit ang(const ang& other) : value{static_cast(180.0 / tdm::pi()) * static_cast(other.value)} { } template::value>::type* = nullptr> explicit ang(const ang& other) : value{static_cast(tdm::pi() / 180.0) * static_cast(other.value)} { } ang& operator+=(const ang& rhs) { value += rhs.value; return *this; } ang& operator-=(const ang& rhs) { value -= rhs.value; return *this; } ang& operator*=(value_type val) { value *= val; return *this; } ang& operator/=(value_type val) { value /= val; return *this; } ang operator-() const { return ang{-value}; } }; #ifdef _MSC_VER #pragma warning(pop) #endif template inline bool operator==(const ang& lhs, const ang& rhs) { return lhs.value == rhs.value; } template inline bool operator!=(const ang& lhs, const ang& rhs) { return !(lhs == rhs); } template inline ang operator+(const ang& lhs, const ang& rhs) { return ang(lhs) += rhs; } template inline ang operator-(const ang& lhs, const ang& rhs) { return ang(lhs) -= rhs; } template inline ang operator*(const ang& lhs, T rhs) { return ang(lhs) *= rhs; } template inline ang operator*(T lhs, const ang& rhs) { return ang(rhs) *= lhs; } template inline ang operator/(const ang& lhs, T rhs) { return ang(lhs) /= rhs; } namespace ang_literals { constexpr fdeg operator""_fdeg(long double angle) { return fdeg{static_cast(angle)}; } constexpr frad operator""_frad(long double angle) { return frad{static_cast(angle)}; } } // namespace ang_literals } // namespace tdm