summaryrefslogtreecommitdiff
path: root/include/JSystem/JMath
diff options
context:
space:
mode:
Diffstat (limited to 'include/JSystem/JMath')
-rw-r--r--include/JSystem/JMath/JMATrigonometric.h21
-rw-r--r--include/JSystem/JMath/JMath.h5
2 files changed, 16 insertions, 10 deletions
diff --git a/include/JSystem/JMath/JMATrigonometric.h b/include/JSystem/JMath/JMATrigonometric.h
index 1b88975794..25b79a72dc 100644
--- a/include/JSystem/JMath/JMATrigonometric.h
+++ b/include/JSystem/JMath/JMATrigonometric.h
@@ -2,8 +2,9 @@
#define JMATRIGONOMETRIC_H
#include "dolphin/types.h"
-#include "utility.h"
+#include <utility.h>
+namespace JMath {
template<typename T>
struct TAngleConstant_;
@@ -19,7 +20,6 @@ struct TAngleConstant_<f32> {
static f32 RADIAN_TO_DEGREE_FACTOR() { return 180.0f / RADIAN_DEG180(); }
};
-namespace JMath {
/**
* @ingroup jsystem-jmath
*
@@ -73,30 +73,31 @@ struct TAtanTable {
* @ingroup jsystem-jmath
*
*/
+template<int N, typename T>
struct TAsinAcosTable {
- f32 table[1025];
+ T table[1025];
u8 pad[0x1C];
- f32 acos_(f32 x) {
+ T acos_(T x) const {
if (x >= 1.0f) {
return 0.0f;
} else if (x <= -1.0f) {
- return TAngleConstant_<f32>::RADIAN_DEG180();
+ return TAngleConstant_<T>::RADIAN_DEG180();
} else if (x < 0.0f) {
- return table[(u32)(-x * 1023.5f)] + TAngleConstant_<f32>::RADIAN_DEG090();
+ return table[(u32)(-x * 1023.5f)] + TAngleConstant_<T>::RADIAN_DEG090();
} else {
- return TAngleConstant_<f32>::RADIAN_DEG090() - table[(u32)(x * 1023.5f)];
+ return TAngleConstant_<T>::RADIAN_DEG090() - table[(u32)(x * 1023.5f)];
}
}
- f32 acosDegree(f32 x) {
- return acos_(x) * TAngleConstant_<f32>::RADIAN_TO_DEGREE_FACTOR();
+ T acosDegree(T x) const {
+ return acos_(x) * TAngleConstant_<T>::RADIAN_TO_DEGREE_FACTOR();
}
};
extern TSinCosTable<13, f32> sincosTable_;
extern TAtanTable atanTable_;
-extern TAsinAcosTable asinAcosTable_;
+extern TAsinAcosTable<1024, f32> asinAcosTable_;
inline f32 acosDegree(f32 x) {
return asinAcosTable_.acosDegree(x);
diff --git a/include/JSystem/JMath/JMath.h b/include/JSystem/JMath/JMath.h
index eb7932e848..4d9dd66608 100644
--- a/include/JSystem/JMath/JMath.h
+++ b/include/JSystem/JMath/JMath.h
@@ -80,6 +80,11 @@ inline f32 JMAHermiteInterpolation(register f32 p1, register f32 p2, register f3
namespace JMath {
+template <typename T>
+inline T fastSqrt(T value) {
+ return JMAFastSqrt(value);
+}
+
inline f32 fastReciprocal(f32 value) {
return JMAFastReciprocal(value);
}