Utilities.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <ionCore.h>
5 #include <cmath>
6 
7 #include "Constants.h"
8 
9 
11 template <typename T>
12 T Abs(T const value)
13 {
14  return std::abs(value);
15 }
16 
21 template <typename T>
22 static T const MaxAbs(T const a, T const b)
23 {
24  return Abs(b) < Abs(a) ? a : b;
25 }
26 
27 
29 template <typename T>
30 T Sin(T const value)
31 {
32  return sin(value);
33 }
34 
36 template <typename T>
37 T Cos(T const value)
38 {
39  return cos(value);
40 }
41 
43 template <typename T>
44 T Tan(T const value)
45 {
46  return tan(value);
47 }
48 
50 template <typename T>
51 T ArcTan(T const value)
52 {
53  return atan(value);
54 }
55 
57 template <typename T>
58 T ArcTan(T const y, T const x)
59 {
60  return atan2(y, x);
61 }
62 
64 template <typename T>
65 T Sqrt(T const value)
66 {
67  return (T) sqrt(value);
68 }
69 
71 template <typename T>
72 T DegToRad(T const degrees)
73 {
74  return degrees * Constants<T>::Pi() / 180;
75 }
76 
78 template <typename T>
79 T RadToDeg(T const radians)
80 {
81  return radians * 180 / Constants<T>::Pi();
82 }
83 
85 template <typename T>
86 bool IsNaN(T const value)
87 {
88  return value != value;
89 }
90 
94 template <typename T>
95 T Saturate(T const value)
96 {
97  return Minimum(1, Maximum(0, value));
98 }
f32 const Pi
Definition: Constants.h:11
T Sin(T const value)
Definition: Utilities.h:30
T Sqrt(T const value)
Definition: Utilities.h:65
T DegToRad(T const degrees)
Definition: Utilities.h:72
T Tan(T const value)
Definition: Utilities.h:44
T RadToDeg(T const radians)
Definition: Utilities.h:79
T Abs(T const value)
Definition: Utilities.h:12
T Saturate(T const value)
Clamps a value between 0 and 1.
Definition: Utilities.h:95
T Cos(T const value)
Definition: Utilities.h:37
T ArcTan(T const value)
Definition: Utilities.h:51
bool IsNaN(T const value)
Definition: Utilities.h:86