fennec
Loading...
Searching...
No Matches
trigonometric.h
1// =====================================================================================================================
2// fennec, a free and open source game engine
3// Copyright © 2025 Medusa Slockbower
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17// =====================================================================================================================
18
19#ifndef FENNEC_MATH_EXT_TRIGONOMETRIC_H
20#define FENNEC_MATH_EXT_TRIGONOMETRIC_H
21
22#include <fennec/math/ext/quaternion.h>
23
24namespace fennec
25{
26
27// Angle Conversions ===================================================================================================
28
29#ifndef FENNEC_DOXYGEN
30template<typename genType>
31constexpr qua<genType> radians(const qua<genType>& degrees) {
32 return qua<genType>(degrees * 0.01745329251994329576923690768489);
33}
34
35template<typename genType>
36constexpr qua<genType> degrees(const qua<genType>& radians) {
37 return qua<genType>(radians * 57.29577951308232087679815481410517);
38}
39
40// Trigonometric Functions =============================================================================================
41
42template<typename genType>
43constexpr qua<genType> sin(const qua<genType>& x) {
44 return qua<genType>(
45 fennec::sin(x.w),
46 fennec::sin(x.x),
47 fennec::sin(x.y),
48 fennec::sin(x.z)
49 );
50}
51
52template<typename genType>
53constexpr qua<genType> cos(const qua<genType>& x) {
54 return qua<genType>(
55 fennec::cos(x.w),
56 fennec::cos(x.x),
57 fennec::cos(x.y),
58 fennec::cos(x.z)
59 );
60}
61
62template<typename genType>
63constexpr qua<genType> tan(const qua<genType>& x) {
64 return qua<genType>(
65 fennec::tan(x.w),
66 fennec::tan(x.x),
67 fennec::tan(x.y),
68 fennec::tan(x.z)
69 );
70}
71
72template<typename genType>
73constexpr qua<genType> asin(const qua<genType>& x) {
74 return qua<genType>(
75 fennec::asin(x.w),
76 fennec::asin(x.x),
77 fennec::asin(x.y),
78 fennec::asin(x.z)
79 );
80}
81
82template<typename genType>
83constexpr qua<genType> acos(const qua<genType>& x) {
84 return qua<genType>(
85 fennec::acos(x.w),
86 fennec::acos(x.x),
87 fennec::acos(x.y),
88 fennec::acos(x.z)
89 );
90}
91
92template<typename genType>
93constexpr qua<genType> atan(const qua<genType>& x) {
94 return qua<genType>(
95 fennec::atan(x.w),
96 fennec::atan(x.x),
97 fennec::atan(x.y),
98 fennec::atan(x.z)
99 );
100}
101
102
103// Hyperbolic Functions ================================================================================================
104
105template<typename genType>
106constexpr qua<genType> sinh(const qua<genType>& x) {
107 return qua<genType>(
108 fennec::sinh(x.w),
109 fennec::sinh(x.x),
110 fennec::sinh(x.y),
111 fennec::sinh(x.z)
112 );
113}
114
115template<typename genType>
116constexpr qua<genType> cosh(const qua<genType>& x) {
117 return qua<genType>(
118 fennec::cosh(x.w),
119 fennec::cosh(x.x),
120 fennec::cosh(x.y),
121 fennec::cosh(x.z)
122 );
123}
124
125template<typename genType>
126constexpr qua<genType> tanh(const qua<genType>& x) {
127 return qua<genType>(
128 fennec::tanh(x.w),
129 fennec::tanh(x.x),
130 fennec::tanh(x.y),
131 fennec::tanh(x.z)
132 );
133}
134
135template<typename genType>
136constexpr qua<genType> asinh(const qua<genType>& x) {
137 return qua<genType>(
138 fennec::asinh(x.w),
139 fennec::asinh(x.x),
140 fennec::asinh(x.y),
141 fennec::asinh(x.z)
142 );
143}
144
145template<typename genType>
146constexpr qua<genType> acosh(const qua<genType>& x) {
147 return qua<genType>(
148 fennec::acosh(x.w),
149 fennec::acosh(x.x),
150 fennec::acosh(x.y),
151 fennec::acosh(x.z)
152 );
153}
154
155template<typename genType>
156constexpr qua<genType> atanh(const qua<genType>& x) {
157 return qua<genType>(
158 fennec::atanh(x.w),
159 fennec::atanh(x.x),
160 fennec::atanh(x.y),
161 fennec::atanh(x.z)
162 );
163}
164#endif
165
166}
167
168#endif // FENNEC_MATH_EXT_TRIGONOMETRIC_H
constexpr genType asinh(genType x)
The Inverse Hyperbolic Sine Function.
Definition trigonometric.h:363
constexpr genType atanh(genType x)
The Inverse Hyperbolic Tangent Function.
Definition trigonometric.h:389
constexpr genType degrees(genType radians)
Converts to , i.e., .
Definition trigonometric.h:182
constexpr genType acos(genType x)
Arc Cosine. Returns an angle whose cosine is /a x.
Definition trigonometric.h:268
constexpr genType atan(genType y_over_x)
Arc Tangent. Returns an angle whose tangent is /a y_over_x.
Definition trigonometric.h:283
constexpr genType tan(genType x)
The Standard Trigonometric Tangent.
Definition trigonometric.h:232
constexpr genType cosh(genType x)
Returns the Hyperbolic Cosine Function, .
Definition trigonometric.h:332
constexpr genType radians(genType degrees)
Converts to , i.e., .
Definition trigonometric.h:168
constexpr genType tanh(genType x)
Returns the Hyperbolic Tangent Function, .
Definition trigonometric.h:344
constexpr genType sin(genType x)
The standard trigonometric sine.
Definition trigonometric.h:204
constexpr genType acosh(genType x)
The Inverse Hyperbolic Cosine Function.
Definition trigonometric.h:376
constexpr genType asin(genType x)
Arc Sine. Returns an angle whose sine is /a x.
Definition trigonometric.h:253
constexpr genType cos(genType x)
The Standard Trigonometric Cosine.
Definition trigonometric.h:218
constexpr genType sinh(genType x)
Returns the Hyperbolic Sine Function, .
Definition trigonometric.h:320