Created deg struct for better usage of degree

This commit is contained in:
2024-04-03 20:59:30 -05:00
parent 74a483da28
commit d0aa1d43d2
5 changed files with 74 additions and 42 deletions

View File

@@ -1,7 +1,6 @@
#include <PSX/GTE/gte.hpp>
#include <math.h>
int32_t sin(int32_t value) {
static int32_t hisin(int32_t value) {
static constexpr int32_t qN = 13;
static constexpr int32_t qA = 12;
static constexpr int32_t B = 19900;
@@ -20,8 +19,12 @@ int32_t sin(int32_t value) {
return c >= 0 ? result : -result;
}
int32_t cos(int32_t value) {
return sin(value + (FULL_CIRCLE/4));
sin_t sin(deg_t value) {
return hisin(value.raw);
}
cos_t cos(deg_t value) {
return hisin(value.raw + (deg_t::full_circle/4));
}
namespace JabyEngine {
@@ -31,7 +34,7 @@ namespace JabyEngine {
int16_t sin;
int16_t cos;
static SinCosPair create_for(int32_t value) {
static SinCosPair create_for(deg_t value) {
return SinCosPair{
.sin = static_cast<int16_t>(::sin(value)),
.cos = static_cast<int16_t>(::cos(value)),
@@ -96,7 +99,7 @@ namespace JabyEngine {
return matrix;
}
ROTMATRIX ROTMATRIX :: rotated(int32_t x, int32_t y, int32_t z) {
ROTMATRIX ROTMATRIX :: rotated(deg_t x, deg_t y, deg_t z) {
using namespace MatrixHelper;
const auto sincos_x = SinCosPair::create_for(x);