mirror of
https://github.com/zeldaret/mm.git
synced 2026-06-24 17:03:09 -04:00
Angle Conversions (#1216)
* Angle Conversions * Format * namefixer * Renames in ObjHsStump_Appear * Format * once more * Explicit cast in EnSsh * Update src/overlays/actors/ovl_En_Fishing/z_en_fishing.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --------- Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
This commit is contained in:
+2
-2
@@ -66,7 +66,7 @@ f32 pow_int(f32 base, s32 exp) {
|
||||
* Takes an angle in radians and returns the sine.
|
||||
*/
|
||||
f32 sin_rad(f32 rad) {
|
||||
return sins(RADF_TO_BINANG(rad)) * SHT_MINV;
|
||||
return sins(RAD_TO_BINANG(rad)) * SHT_MINV;
|
||||
}
|
||||
|
||||
// Rename to Math_CosF
|
||||
@@ -74,7 +74,7 @@ f32 sin_rad(f32 rad) {
|
||||
* Takes an angle in radians and returns the cosine.
|
||||
*/
|
||||
f32 cos_rad(f32 rad) {
|
||||
return coss(RADF_TO_BINANG(rad)) * SHT_MINV;
|
||||
return coss(RAD_TO_BINANG(rad)) * SHT_MINV;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -127,7 +127,7 @@ s16 Math_Atan2S(f32 y, f32 x) {
|
||||
}
|
||||
|
||||
f32 Math_Atan2F(f32 y, f32 x) {
|
||||
return Math_Atan2S(y, x) * (M_PI / 0x8000);
|
||||
return BINANG_TO_RAD(Math_Atan2S(y, x));
|
||||
}
|
||||
|
||||
// Match the OoT implementation of Math_Atan2S
|
||||
|
||||
@@ -444,8 +444,8 @@ void Matrix_RotateXFApply(f32 x) {
|
||||
if (x != 0.0f) {
|
||||
cmf = sCurrentMatrix;
|
||||
|
||||
sin = sins(RADF_TO_BINANG(x)) * SHT_MINV;
|
||||
cos = coss(RADF_TO_BINANG(x)) * SHT_MINV;
|
||||
sin = sins(RAD_TO_BINANG(x)) * SHT_MINV;
|
||||
cos = coss(RAD_TO_BINANG(x)) * SHT_MINV;
|
||||
|
||||
tempY = cmf->xy;
|
||||
tempZ = cmf->xz;
|
||||
|
||||
+6
-6
@@ -123,14 +123,14 @@ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) {
|
||||
if ((dist == 0.0f) && (vec->y == 0.0f)) {
|
||||
sph.pitch = 0;
|
||||
} else {
|
||||
sph.pitch = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(dist, vec->y)));
|
||||
sph.pitch = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(dist, vec->y)));
|
||||
}
|
||||
|
||||
sph.r = sqrtf(SQ(vec->y) + distSquared);
|
||||
if ((vec->x == 0.0f) && (vec->z == 0.0f)) {
|
||||
sph.yaw = 0;
|
||||
} else {
|
||||
sph.yaw = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(vec->x, vec->z)));
|
||||
sph.yaw = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(vec->x, vec->z)));
|
||||
}
|
||||
|
||||
*dest = sph;
|
||||
@@ -220,8 +220,8 @@ Vec3f* OLib_Vec3fDiffDegF(Vec3f* dest, Vec3f* a, Vec3f* b) {
|
||||
|
||||
OLib_Vec3fDiffRad(&anglesRad, a, b);
|
||||
|
||||
anglesDegrees.x = RADF_TO_DEGF(anglesRad.x);
|
||||
anglesDegrees.y = RADF_TO_DEGF(anglesRad.y);
|
||||
anglesDegrees.x = RAD_TO_DEG(anglesRad.x);
|
||||
anglesDegrees.y = RAD_TO_DEG(anglesRad.y);
|
||||
anglesDegrees.z = 0.0f;
|
||||
|
||||
*dest = anglesDegrees;
|
||||
@@ -238,8 +238,8 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b) {
|
||||
|
||||
OLib_Vec3fDiffRad(&anglesRad, a, b);
|
||||
|
||||
anglesBinAng.x = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.x));
|
||||
anglesBinAng.y = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.y));
|
||||
anglesBinAng.x = CAM_DEG_TO_BINANG(RAD_TO_DEG(anglesRad.x));
|
||||
anglesBinAng.y = CAM_DEG_TO_BINANG(RAD_TO_DEG(anglesRad.y));
|
||||
anglesBinAng.z = 0.0f;
|
||||
|
||||
*dest = anglesBinAng;
|
||||
|
||||
+3
-3
@@ -825,9 +825,9 @@ void Distortion_Update(void) {
|
||||
screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep);
|
||||
|
||||
View_SetDistortionOrientation(&sDistortionRequest.play->view,
|
||||
Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor),
|
||||
Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor),
|
||||
Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor));
|
||||
Math_CosS(depthPhase) * (DEG_TO_RAD(rotX) * xyScaleFactor),
|
||||
Math_SinS(depthPhase) * (DEG_TO_RAD(rotY) * xyScaleFactor),
|
||||
Math_SinS(screenPlanePhase) * (DEG_TO_RAD(rotZ) * zScaleFactor));
|
||||
View_SetDistortionScale(&sDistortionRequest.play->view,
|
||||
(Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f,
|
||||
(Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f,
|
||||
|
||||
+4
-4
@@ -577,7 +577,7 @@ s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) {
|
||||
diffZ = points[index + 1].z - points[index - 1].z;
|
||||
}
|
||||
|
||||
func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d);
|
||||
func_8017B7F8(&point, RAD_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d);
|
||||
if (((px * actor->world.pos.x) + (pz * actor->world.pos.z) + d) > 0.0f) {
|
||||
reached = true;
|
||||
}
|
||||
@@ -1023,13 +1023,13 @@ s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f3
|
||||
f32 step;
|
||||
f32 prevRotStep;
|
||||
|
||||
step = (f32)(target - *rot) * (360.0f / (f32)0x10000);
|
||||
step = BINANG_TO_DEG(target - *rot);
|
||||
step *= gFramerateDivisorHalf;
|
||||
prevRotStep = step;
|
||||
if (step >= 0.0f) {
|
||||
step /= slowness;
|
||||
step = CLAMP(step, stepMin, stepMax);
|
||||
*rot += (s16)((step * (f32)0x10000) / 360.0f);
|
||||
*rot += DEG_TO_BINANG_ALT2(step);
|
||||
if (prevRotStep < stepMin) {
|
||||
*rot = target;
|
||||
}
|
||||
@@ -1039,7 +1039,7 @@ s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f3
|
||||
} else {
|
||||
step = (step / slowness) * -1.0f;
|
||||
step = CLAMP(step, stepMin, stepMax);
|
||||
*rot -= (s16)((step * (f32)0x10000) / 360.0f);
|
||||
*rot -= DEG_TO_BINANG_ALT2(step);
|
||||
if (-stepMin < prevRotStep) {
|
||||
*rot = target;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user