#pragma once #include "stdint.hpp" namespace math { template struct raw_math { constexpr T operator-() const { return T{.raw = static_cast(-(static_cast(*this).raw))}; } constexpr T operator+(const T& obj) const { return T{.raw = static_cast(*this).raw + obj.raw}; } constexpr T operator-(const T& b) const {} constexpr T& operator+=(const T& obj) { static_cast(*this).raw += obj.raw; return static_cast(*this); } constexpr T& operator-=(const T& obj) { static_cast(*this).raw -= obj.raw; return static_cast(*this); } }; } struct deg_t : public math::raw_math { static constexpr auto full_circle = 32768; static constexpr auto one_degree = full_circle/360; static constexpr auto one_tenth_degree = full_circle/3600; int16_t raw; static constexpr deg_t zero() { return deg_t{.raw = 0}; } static constexpr deg_t from_degree(int32_t deg) { return deg_t{.raw = static_cast(deg*one_degree)}; } static constexpr deg_t from_tenth_degree(int32_t deg10) { return deg_t{.raw = static_cast(deg10*one_tenth_degree)}; } }; static constexpr deg_t operator""_deg(long double degree) { return deg_t::from_tenth_degree((degree*10.0)); } struct gte_float : public math::raw_math { int32_t raw; static constexpr gte_float from_double(double value) { return gte_float{.raw = static_cast(4096.0*value)}; } static constexpr gte_float one() { return gte_float::from_double(1.0); } constexpr explicit operator int32_t() const { return this->raw; } constexpr explicit operator int16_t() const { return static_cast(this->raw); } }; static constexpr gte_float operator""_gf(long double value) { return gte_float::from_double(value); } gte_float sin(deg_t value); gte_float cos(deg_t value);