Faro Engine 0.0.0.b519570 (main)
Loading...
Searching...
No Matches
MathUtil.hpp
Go to the documentation of this file.
1#pragma once
2#include "../Primitives.hpp"
3#include <random>
4
5namespace Faro
6{
7 // PI math
8 extern float Pi();
9
10 // default precision: 0
11 extern void SetPIPrecision(int);
12
13 template<class T>
14 T DegToRad(T degrees) { return (degrees * (T)Pi()) / 180.0f; }
15
16 template<class T>
17 T RadToDeg(T radians) { return (radians * 180.0f / (T)Pi()); }
18
19 template<class T>
20 T Min(T a, T b)
21 {
22 return (a <= b) ? a : b;
23 }
24
25 template<class T>
26 T Max(T a, T b)
27 {
28 return (a >= b) ? a : b;
29 }
30
31 template<class T>
32 T Sin(T a)
33 {
34 return std::sin(a);
35 }
36
37 template<class T>
38 T Cos(T a)
39 {
40 return std::cos(a);
41 }
42
43 template<class T>
44 T Tan(T a)
45 {
46 return std::tan(a);
47 }
48
49 template<class T>
50 T SinDeg(T a)
51 {
52 return std::sin(DegToRad(a));
53 }
54
55 template<class T>
56 T CosDeg(T a)
57 {
58 return std::cos(DegToRad(a));
59 }
60
61 template<class T>
62 T TanDeg(T a)
63 {
64 return std::tan(DegToRad(a));
65 }
66
67 template<class T>
68 T ASin(T a)
69 {
70 return std::asin(a);
71 }
72
73 template<class T>
74 T ACos(T a)
75 {
76 return std::acos(a);
77 }
78
79 template<class T>
80 T ATan(T a)
81 {
82 return std::atan(a);
83 }
84
85 template<class T>
86 T ASinDeg(T a)
87 {
88 return RadToDeg(std::asin(a));
89 }
90
91 template<class T>
92 T ACosDeg(T a)
93 {
94 return RadToDeg(std::acos(a));
95 }
96
97 template<class T>
98 T ATanDeg(T a)
99 {
100 return RadToDeg(std::atan(a));
101 }
102
103 template<class T, class AlphaType>
104 T Lerp(T a, T b, AlphaType alpha)
105 {
106 return a + (b - a) * alpha;
107 }
108}
Definition Array.hpp:8
T Sin(T a)
Definition MathUtil.hpp:32
T RadToDeg(T radians)
Definition MathUtil.hpp:17
T ASinDeg(T a)
Definition MathUtil.hpp:86
T ATanDeg(T a)
Definition MathUtil.hpp:98
T ACos(T a)
Definition MathUtil.hpp:74
void SetPIPrecision(int)
Definition MathUtil.cpp:11
T Lerp(T a, T b, AlphaType alpha)
Definition MathUtil.hpp:104
T TanDeg(T a)
Definition MathUtil.hpp:62
T Cos(T a)
Definition MathUtil.hpp:38
float Pi()
Definition MathUtil.cpp:5
T Tan(T a)
Definition MathUtil.hpp:44
T ATan(T a)
Definition MathUtil.hpp:80
T DegToRad(T degrees)
Definition MathUtil.hpp:14
T Max(T a, T b)
Definition MathUtil.hpp:26
T SinDeg(T a)
Definition MathUtil.hpp:50
T CosDeg(T a)
Definition MathUtil.hpp:56
T ASin(T a)
Definition MathUtil.hpp:68
T ACosDeg(T a)
Definition MathUtil.hpp:92
T Min(T a, T b)
Definition MathUtil.hpp:20