forked from HarbourMasters/Starship
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibc_math64.c
99 lines (83 loc) · 1.59 KB
/
libc_math64.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "sys.h"
f32 Math_TanF(f32 x) {
return tanf(x);
}
f32 Math_FloorF(f32 x) {
return floorf(x);
}
f32 Math_CeilF(f32 x) {
return ceilf(x);
}
f64 Math_Fabs(f64 x) {
return (x < 0.0) ? -x : x;
}
f32 Math_FabsF(f32 x) {
return (x < 0.0f) ? -x : x;
}
f32 Math_NearbyIntF(f32 x) {
return __nearbyintf(x);
}
f32 Math_TruncF(f32 x) {
return __truncf(x);
}
f32 Math_RoundF(f32 x) {
return __roundf(x);
}
f32 Math_FAtanF(f32 x) {
return atanf(x);
/*
s32 sector;
s32 i;
f32 sq;
f32 conv = 0.0f;
f32 z;
if (x > 1.0f) {
sector = 1;
x = 1.0f / x;
} else if (x < -1.0f) {
sector = -1;
x = 1.0f / x;
} else {
sector = 0;
}
sq = SQ(x);
for (z = i = 24; i != 0; i--) {
conv = SQ(z) * sq / (2.0f * z + 1.0f + conv);
z -= 1.0f;
}
if (sector > 0) {
return M_PI / 2.0f - (x / (1.0f + conv));
} else if (sector < 0) {
return -M_PI / 2.0f - (x / (1.0f + conv));
} else {
return x / (1.0f + conv);
}
*/
}
f32 Math_FAtan2F(f32 y, f32 x) {
return atan2f(y, x);
/*
if ((y == 0.0f) && (x == 0.0f)) {
return 0.0f;
}
if (x == 0.0f) {
if (y < 0.0f) {
return -M_PI / 2.0f;
}
return M_PI / 2.0f;
}
if (x < 0.0f) {
if (y < 0.0f) {
return -(M_PI - Math_FAtanF(fabs(y / x)));
}
return M_PI - Math_FAtanF(fabs(y / x));
}
return Math_FAtanF(y / x);
*/
}
f32 Math_FAsinF(f32 x) {
return asinf(x);
}
f32 Math_FAcosF(f32 x) {
return acosf(x);
}