Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1#ifndef MSL_MATH_H_
2#define MSL_MATH_H_
3
4#include "float.h"
5
6#define NAN (*(float*) __float_nan)
7#define HUGE_VALF (*(float*) __float_huge)
8
9#define M_PI 3.14159265358979323846f
10#define M_SQRT3 1.73205f
11
12#define DEG_TO_RAD(degrees) (degrees * (M_PI / 180.0f))
13#define RAD_TO_DEG(radians) (radians / (180.0f / M_PI))
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19int abs(int);
20double acos(double);
21float acosf(float);
22double asin(double);
23double atan(double);
24double atan2(double, double);
25double ceil(double);
26double copysign(double, double);
27double cos(double);
28float cosf(float);
29double exp(double);
30
31extern double __frsqrte(double);
32extern float __fres(float);
33
34extern double __fabs(double);
35extern float __fabsf(float);
36inline double fabs(double f) {
37 return __fabs(f);
38}
39inline double fabsf2(float f) {
40 return __fabsf(f);
41}
42inline float fabsf(float f) {
43 return fabsf2(f);
44}
45
46double floor(double);
47double fmod(double, double);
48inline float fmodf(float f1, float f2) {
49 return fmod(f1, f2);
50}
51
52double frexp(double, int*);
53double ldexp(double, int);
54double modf(double, double*);
55double pow(double, double);
56double sin(double);
57float sinf(float);
58double sqrt(double);
59double tan(double);
60float tanf(float);
61
62inline double sqrt_step(double tmpd, float mag) {
63 return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd));
64}
65
66inline float sqrtf(float mag) {
67 if (mag > 0.0f) {
68 double tmpd = __frsqrte(mag);
69 tmpd = sqrt_step(tmpd, mag);
70 tmpd = sqrt_step(tmpd, mag);
71 tmpd = sqrt_step(tmpd, mag);
72 return mag * tmpd;
73 } else if (mag < 0.0) {
74 return NAN;
75 } else if (fpclassify(mag) == 1) {
76 return NAN;
77 } else {
78 return mag;
79 }
80}
81
82inline float atan2f(float y, float x) {
83 return (float)atan2(y, x);
84}
85
86inline float i_sinf(float x) { return sin(x); }
87inline float i_cosf(float x) { return cos(x); }
88inline float i_tanf(float x) { return tan(x); }
89
90#ifdef __cplusplus
91};
92#endif
93
94#endif
void floor()
void fmod()
void ceil()
double x double x
Definition e_atan2.c:58
double x double y
Definition e_atan2.c:58
double atan2(double, double)
Definition w_atan2.c:4
float cosf(float)
Definition d_kankyo.cpp:26
int abs(int)
Definition arith.c:4
float tanf(float)
float sinf(float)
Definition d_kankyo.cpp:22
float i_cosf(float x)
Definition math.h:87
float i_tanf(float x)
Definition math.h:88
float sqrtf(float mag)
Definition math.h:66
double frexp(double, int *)
double acos(double)
Definition w_acos.c:4
float acosf(float)
double modf(double, double *)
double cos(double)
float __fabsf(float)
double __fabs(double)
double copysign(double, double)
double pow(double, double)
Definition w_pow.c:4
float fmodf(float f1, float f2)
Definition math.h:48
double ldexp(double, int)
Definition s_ldexp.c:22
double sqrt_step(double tmpd, float mag)
Definition math.h:62
double atan(double)
double __frsqrte(double)
double fabs(double f)
Definition math.h:36
float fabsf(float f)
Definition math.h:42
double tan(double)
double sqrt(double)
Definition w_sqrt.c:4
float __fres(float)
double sin(double)
double asin(double)
Definition w_asin.c:4
double exp(double)
Definition w_exp.c:4
float i_sinf(float x)
Definition math.h:86
float atan2f(float y, float x)
Definition math.h:82
double fabsf2(float f)
Definition math.h:39