mirror of https://github.com/zeldaret/tp.git
50 lines
928 B
C++
50 lines
928 B
C++
#ifndef JMATRIGONOMETRIC_H
|
|
#define JMATRIGONOMETRIC_H
|
|
|
|
#include "dolphin/types.h"
|
|
|
|
namespace std {
|
|
template <typename A1, typename B1>
|
|
struct pair {
|
|
A1 a1;
|
|
B1 b1;
|
|
pair() {
|
|
a1 = A1();
|
|
b1 = B1();
|
|
}
|
|
};
|
|
} // namespace std
|
|
|
|
struct TSinCosTable {
|
|
std::pair<f32, f32> table[0x2000];
|
|
|
|
f32 sinShort(s16 v) const { return table[static_cast<u16>(v) >> 3].a1; }
|
|
f32 cosShort(s16 v) const { return table[static_cast<u16>(v) >> 3].b1; }
|
|
};
|
|
|
|
struct TAtanTable {
|
|
f32 table[1025];
|
|
u8 pad[0x1C];
|
|
};
|
|
|
|
struct TAsinAcosTable {
|
|
f32 table[1025];
|
|
u8 pad[0x1C];
|
|
};
|
|
|
|
namespace JMath {
|
|
extern TSinCosTable sincosTable_;
|
|
extern TAtanTable atanTable_;
|
|
extern TAsinAcosTable asinAcosTable_;
|
|
}; // namespace JMath
|
|
|
|
inline f32 JMASSin(s16 s) {
|
|
return JMath::sincosTable_.sinShort(s);
|
|
}
|
|
|
|
inline f32 JMASCos(s16 s) {
|
|
return JMath::sincosTable_.cosShort(s);
|
|
}
|
|
|
|
#endif /* JMATRIGONOMETRIC_H */
|