prime/include/Kyoto/Math/CMath.hpp

77 lines
2.4 KiB
C++
Raw Normal View History

2022-09-05 04:00:04 +00:00
#ifndef _CMATH_HPP
#define _CMATH_HPP
#include "types.h"
2022-09-29 05:30:20 +00:00
#include "math.h"
2022-09-21 05:18:07 +00:00
#define M_PIF 3.14159265358979323846f
2022-09-05 04:00:04 +00:00
class CMath {
public:
static f32 FastCosR(f32 v);
static f32 FastSinR(f32 v);
static inline f32 FastFmod(f32 x, f32 y) {
int v = static_cast< int >(x * (1.f / y));
2022-09-05 04:00:04 +00:00
return x - v * y;
}
template < typename T >
2022-09-29 05:30:20 +00:00
static const T& Clamp(const T& min, const T& val, const T& max); // TODO: weak
2022-09-21 05:18:07 +00:00
static f32 SqrtF(f32 v);
2022-09-29 05:30:20 +00:00
static inline f32 Limit(f32 v, f32 h) { return fabs(v) > h ? h * Sign(v) : v; }
static inline f32 Sign(f32 v) { return FastFSel(v, 1.f, -1.f); }
static inline f32 FastFSel(register f32 v, register f32 h, register f32 l) {
register f32 out;
asm {
fsel out, v, h, l
}
return out;
}
static inline f32 AbsF(f32 v) { return fabs(v); }
static inline f64 AbsD(f64 v) { return fabs(v); }
static inline int AbsI(int v) { return abs(v); }
2022-09-29 05:30:20 +00:00
// WrapPi__5CMathFf weak
// WrapTwoPi__5CMathFf weak
// FastFmod__5CMathFfff weak
template < typename T >
static const T& Min(const T& a, const T& b);
template < typename T >
static const T& Max(const T& a, const T& b);
2022-09-29 05:30:20 +00:00
// InvSqrtF__5CMathFf global
// FastArcCosR__5CMathFf global
// SlowCosineR__5CMathFf global
// SlowSineR__5CMathFf global
// FastCosR__5CMathFf global
// GetBezierPoint__5CMathFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3ff global
2022-10-05 23:06:15 +00:00
static f32 ClampRadians(f32 rad) {
f32 value = rad - static_cast<int>(rad * (M_PIF * 2.f)) * (M_PIF * 2.f);
if (value < 0.f) {
value += (M_PIF * 2.f);
}
return value;
}
2022-09-29 05:30:20 +00:00
// ModF__5CMathFff weak
static f32 Deg2Rad(f32 deg) { return Deg2Rev(deg) * (M_PIF * 2.f); }
static f32 Deg2Rev(f32 deg) { return deg * (1.f / 360.f); }
static f32 ArcCosineR(f32 v);
2022-09-29 05:30:20 +00:00
// FloorF__5CMathFf global
// BaryToWorld__5CMathFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3f global
// GetCatmullRomSplinePoint__5CMathFRC9CVector3fRC9CVector3fRC9CVector3fRC9CVector3ff global
// FastSqrtF__5CMathFf weak
static double SqrtD(double x);
2022-09-29 05:30:20 +00:00
// IsEpsilon__5CMathFfff global
// FastMin__5CMathFff weak
// FastMax__5CMathFff weak
// PowF__5CMathFff global
// Rev2Deg__5CMathFf weak
// GetCatmullRomSplinePoint__5CMathFfffff global
// SlowTangentR__5CMathFf global
// Rad2Deg__5CMathFf weak
// Rad2Rev__5CMathFf weak
// CeilingF__5CMathFf global
// ArcTangentR__5CMathFf global
// Swap<f>__5CMathFRfRf weak
2022-09-05 04:00:04 +00:00
};
2022-09-13 04:52:59 +00:00
#endif