Melee Modding Library  2.0.0
A C library for modding Super Smash Bros Melee
math.h
Go to the documentation of this file.
1 
7 #ifndef MML_MATH_H
8 #define MML_MATH_H
9 
10 #include "gctypes.h"
11 
13 #define M_PI 3.14159265358f
14 
16 #define M_2PI 6.28318530718f
17 
19 #define M_PI_OVER_2 1.57079632679f
20 #define M_HALF_PI M_PI_OVER_2 //TODO: remove for v2
21 
23 #define M_PI_OVER_3 1.047197551f
24 
26 #define M_PI_OVER_4 0.785398163f
27 
29 #define M_PI_OVER_6 0.523598776f
30 
32 #define DEG_TO_RAD(x) ((x) * 0.01745329251f)
33 
35 #define RAD_TO_DEG(x) ((x) * 57.2957795131f)
36 
38 #define SIGN(x) ((x) < 0 ? -1 : 1)
39 
43 typedef struct
44 {
45  float x;
46  float y;
48 } Point;
49 
51 extern float (*fabs)(float x);
52 extern float (*recipSqrt)(float x);
53 extern float (*exp)(float x);
54 extern float (*log)(float x);
55 
56 extern float (*native_sin)(float x);
57 extern float (*native_cos)(float x);
58 extern float (*native_tan)(float x);
59 extern float (*native_acos)(float x);
60 extern float (*native_asin)(float x);
61 extern float (*native_atan)(float x);
62 extern float (*native_atan2)(float y, float x);
63 
64 #if 0
65 
74 float exp(float x);
75 
83 float log(float x);
84 
92 float fabs(float x);
93 
101 float recipSqrt(float x);
102 
104 #endif
105 
119 float floor(float x);
120 
133 float ceil(float x);
134 
143 s32 imax(s32 a, s32 b);
144 
153 s32 imin(s32 a, s32 b);
154 
163 float fmax(float a, float b);
164 
173 float fmin(float a, float b);
174 
183 int imod(int a, int b);
184 
193 float fmod(float a, float b);
194 
203 s32 ipow(s16 base, u8 exp);
204 
213 float fpow(float base, u8 exp);
214 
222 float sqrt(float x);
223 
231 float sin(float x);
232 
240 float cos(float x);
241 
249 float tan(float x);
250 
259 float asin(float x);
260 
269 float acos(float x);
270 
279 float atan(float x);
280 
296 float atan2(float y, float x);
297 
307 float magnitude(Point pt);
308 
317 float distance(Point a, Point b);
318 
327 float angle(Point a, Point b);
328 
329 #endif
uint8_t u8
Definition: gctypes.h:14
float fmin(float a, float b)
Minimum of two floating-point values.
Definition: math.c:53
float acos(float x)
Arc cosine of x.
Definition: math.c:126
Data types for the gamecube.
float ceil(float x)
Round up value.
Definition: math.c:33
Struct containing the coordinates of a point.
Definition: math.h:43
float recipSqrt(float x)
1 / sqrt(x)
float atan(float x)
Arc tangent of x.
Definition: math.c:131
float magnitude(Point pt)
Magnitude of point.
Definition: math.c:146
float x
Definition: math.h:45
float y
Definition: math.h:46
s32 imin(s32 a, s32 b)
Minimum of two integers.
Definition: math.c:43
float angle(Point a, Point b)
Angle between two points.
Definition: math.c:141
float asin(float x)
Arc sine of x.
Definition: math.c:121
float fmax(float a, float b)
Maximum of two floating-point values.
Definition: math.c:48
float sqrt(float x)
Square root of x.
Definition: math.c:101
int16_t s16
Definition: gctypes.h:19
float atan2(float y, float x)
Compute arc tangent with two parameters.
Definition: math.c:136
float log(float x)
natural log
int imod(int a, int b)
Mod operator for integers.
Definition: math.c:58
float fmod(float a, float b)
Mod operator for floats.
Definition: math.c:64
float fabs(float x)
Absolute value of x.
float floor(float x)
Round down value.
Definition: math.c:20
float cos(float x)
Cosine of x, expressed in degrees.
Definition: math.c:111
s32 imax(s32 a, s32 b)
Maximum of two integers.
Definition: math.c:38
float distance(Point a, Point b)
Distance between two points.
Definition: math.c:151
s32 ipow(s16 base, u8 exp)
base raised to the power of exp
Definition: math.c:71
int32_t s32
Definition: gctypes.h:20
float sin(float x)
Sine of x, expressed in degrees.
Definition: math.c:106
float fpow(float base, u8 exp)
base raised to the power of exp
Definition: math.c:86
float tan(float x)
Tangent of x, expressed in degrees.
Definition: math.c:116
float exp(float x)
e to the power x