AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AAngleRadians.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13
14#include <AUI/Core.h>
15#include <type_traits>
16#include <cassert>
17#include <ostream>
18#include <tuple>
19#include <glm/glm.hpp>
20
21class AString;
22
41class API_AUI_VIEWS AAngleRadians
42{
43public:
44 constexpr AAngleRadians() noexcept = default;
45 constexpr explicit AAngleRadians(float radians) noexcept: mValue(radians) {}
46
47 [[nodiscard]]
48 constexpr float radians() const noexcept {
49 return mValue;
50 }
51
52 [[nodiscard]]
53 constexpr float degrees() const noexcept {
54 return glm::degrees(mValue);
55 }
56
57 AAngleRadians& operator+=(AAngleRadians rhs) noexcept {
58 mValue += rhs.mValue;
59 return *this;
60 }
61
62 AAngleRadians& operator-=(AAngleRadians rhs) noexcept {
63 mValue -= rhs.mValue;
64 return *this;
65 }
66
67 AAngleRadians& operator*=(float k) noexcept {
68 mValue *= k;
69 return *this;
70 }
71
72 AAngleRadians& operator/=(float k) noexcept {
73 mValue /= k;
74 return *this;
75 }
76
77 AAngleRadians operator+(AAngleRadians rhs) const noexcept {
78 return AAngleRadians(mValue + rhs.mValue);
79 }
80
81 AAngleRadians operator-(AAngleRadians rhs) const noexcept {
82 return AAngleRadians(mValue - rhs.mValue);
83 }
84
85 AAngleRadians operator*(float k) const noexcept {
86 return AAngleRadians(mValue * k);
87 }
88
89 AAngleRadians operator/(float k) const noexcept {
90 return AAngleRadians(mValue / k);
91 }
92
93private:
94 float mValue = 0.f;
95};
96
97
98constexpr inline AAngleRadians operator""_rad(long double v)
99{
100 return AAngleRadians(v);
101}
102constexpr inline AAngleRadians operator""_deg(long double v)
103{
104 return AAngleRadians(glm::radians(v));
105}
106constexpr inline AAngleRadians operator""_deg(unsigned long long v)
107{
108 return AAngleRadians(glm::radians(float(v)));
109}
110
111inline std::ostream& operator<<(std::ostream& o, const AAngleRadians& value) {
112 o << value.degrees() << "deg";
113 return o;
114}
Strong type used to store angle in radians.
Definition: AAngleRadians.h:42
Represents a Unicode character string.
Definition: AString.h:37