summaryrefslogtreecommitdiff
path: root/src/code/sys_math_atan.c
diff options
context:
space:
mode:
authorEllipticEllipsis <elliptic.ellipsis@gmail.com>2022-06-19 04:14:55 +0100
committerGitHub <noreply@github.com>2022-06-19 04:14:55 +0100
commit7ca70d496dfdcab4a4132eb1e02887d7a1715637 (patch)
tree51cf99a5a5c54925daef36caca6fac794d8d9690 /src/code/sys_math_atan.c
parent56c517dc0741be9c033e204b564528c46562c730 (diff)
Change `Rand_Next` to `u32`, document `rand.c` a bit more (#819)
* Change Rand_Next to u32, document rand.c a bit more * Clean up the quotes a bit, add another note * Format * — -> - * Review * Remove unnecessary casts * Remove quote, reformat the comments * Fix new files * Make docs a bit more consistent and specific * Format
Diffstat (limited to 'src/code/sys_math_atan.c')
-rw-r--r--src/code/sys_math_atan.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c
index 09f355d64..d68e1e293 100644
--- a/src/code/sys_math_atan.c
+++ b/src/code/sys_math_atan.c
@@ -77,57 +77,57 @@ u16 sATan2Tbl[] = {
0x1FF6, 0x1FFB, 0x2000,
};
-u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent) {
- return sATan2Tbl[(s32)((opposite / adjacent) * 0x400)];
+u16 Math_GetAtan2Tbl(f32 y, f32 x) {
+ return sATan2Tbl[(s32)((y / x) * 0x400)];
}
-s16 Math_Atan2S(f32 opposite, f32 adjacent) {
+s16 Math_Atan2S(f32 y, f32 x) {
s32 angle;
- if (opposite == 0.0f) {
- if (adjacent >= 0.0f) {
+ if (y == 0.0f) {
+ if (x >= 0.0f) {
angle = 0;
} else {
angle = 0x8000;
}
- } else if (adjacent == 0.0f) {
- if (opposite >= 0.0f) {
+ } else if (x == 0.0f) {
+ if (y >= 0.0f) {
angle = 0x4000;
} else {
angle = 0xC000;
}
- } else if (opposite >= 0.0f) {
- if (adjacent >= 0.0f) {
- if (opposite <= adjacent) {
- angle = Math_GetAtan2Tbl(opposite, adjacent);
+ } else if (y >= 0.0f) {
+ if (x >= 0.0f) {
+ if (y <= x) {
+ angle = Math_GetAtan2Tbl(y, x);
} else {
- angle = 0x4000 - Math_GetAtan2Tbl(adjacent, opposite);
+ angle = 0x4000 - Math_GetAtan2Tbl(x, y);
}
} else {
- if (-adjacent < opposite) {
- angle = Math_GetAtan2Tbl(-adjacent, opposite) + 0x4000;
+ if (-x < y) {
+ angle = Math_GetAtan2Tbl(-x, y) + 0x4000;
} else {
- angle = 0x8000 - Math_GetAtan2Tbl(opposite, -adjacent);
+ angle = 0x8000 - Math_GetAtan2Tbl(y, -x);
}
}
- } else if (adjacent < 0.0f) {
- if (-opposite <= -adjacent) {
- angle = Math_GetAtan2Tbl(-opposite, -adjacent) + 0x8000;
+ } else if (x < 0.0f) {
+ if (-y <= -x) {
+ angle = Math_GetAtan2Tbl(-y, -x) + 0x8000;
} else {
- angle = 0xC000 - Math_GetAtan2Tbl(-adjacent, -opposite);
+ angle = 0xC000 - Math_GetAtan2Tbl(-x, -y);
}
} else {
- if (adjacent < -opposite) {
- angle = Math_GetAtan2Tbl(adjacent, -opposite) + 0xC000;
+ if (x < -y) {
+ angle = Math_GetAtan2Tbl(x, -y) + 0xC000;
} else {
- angle = -Math_GetAtan2Tbl(-opposite, adjacent);
+ angle = -Math_GetAtan2Tbl(-y, x);
}
}
return angle;
}
-f32 Math_Atan2F(f32 opposite, f32 adjacent) {
- return Math_Atan2S(opposite, adjacent) * (M_PI / 0x8000);
+f32 Math_Atan2F(f32 y, f32 x) {
+ return Math_Atan2S(y, x) * (M_PI / 0x8000);
}
s16 Math_FAtan2F(f32 adjacent, f32 opposite) {