Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
CalculateArcsinDeg.inc.c File Reference

Go to the source code of this file.

Functions

u32 N ArcsinDeg (f32 x, f32 y)
 

Function Documentation

◆ ArcsinDeg()

u32 N ArcsinDeg ( f32 x,
f32 y )

Definition at line 18 of file CalculateArcsinDeg.inc.c.

18 {
19 f32 sinAngle = abs(y) / length2D(x, y);
20 u16 minAngle = 0;
21 u16 maxAngle = 90;
22 u16 ret;
23 u16 i;
24
25 for (i = 0; i < 7; i++) {
26 u16 midAngle = minAngle + ((maxAngle - minAngle) / 2);
27
28 if (N(sinTable)[midAngle] < sinAngle) {
29 minAngle = midAngle;
30 } else {
31 maxAngle = midAngle;
32 }
33 }
34
35 if (fabsf(N(sinTable)[minAngle] - sinAngle) < fabsf(N(sinTable)[maxAngle] - sinAngle)) {
36 ret = minAngle;
37 } else {
38 ret = maxAngle;
39 }
40
41 if (x < 0.0f && y >= 0.0f) {
42 ret = 180 - ret;
43 }
44
45 if (x < 0.0f && y < 0.0f) {
46 ret += 180;
47 }
48
49 if (x >= 0.0f && y < 0.0f) {
50 ret = 360 - ret;
51 }
52
53 return ret;
54}
f32 fabsf(f32 f)
f32 length2D(f32 x, f32 y)
Definition 43F0.c:59