-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxmath.h
108 lines (94 loc) · 3.76 KB
/
xmath.h
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
100
101
102
103
104
105
106
107
108
/**
* This file belongs to the 'xlab' game engine.
* Copyright 2009 xfacter
* Copyright 2016 wickles
* This work is licensed under the LGPLv3
* subject to all terms as reproduced in the included LICENSE file.
*/
#pragma once
#include "xconfig.h"
#include <math.h>
#ifdef __cplusplus
extern "C" {
#endif
#define X_PI (3.1415926536f)
#define X_EULER (2.7182818285f)
#define X_ROOT2 (1.4142135624f)
#define X_ROOT3 (1.7320508076f)
#define X_EPSILON (1.0e-6)
#define DEG_TO_RAD(DEG) ((DEG)*X_PI/180)
#define RAD_TO_DEG(RAD) ((RAD)*180/X_PI)
#define SQR(X) ((X)*(X))
/* possibly add an error variable to see if a domain or other error occurred */
void x_srand(u32 s);
void x_auto_srand();
int x_randi(int min, int max);
float x_randf(float min, float max);
float x_sqrtf(float x);
float x_modf(float x, float y);
float x_sinf(float x);
float x_cosf(float x);
float x_tanf(float x);
float x_asinf(float x);
float x_acosf(float x);
float x_atanf(float x);
float x_atan2f(float y, float x);
float x_sinhf(float x);
float x_coshf(float x);
float x_tanhf(float x);
void x_sincos(float rad, float* sin, float* cos);
float x_expf(float x);
float x_log10f(float x);
float x_logbf(float b, float x);
float x_logef(float x);
float x_powf(float x, float pow);
int x_next_pow2(int x);
int x_num_align(int x, int num);
int x_absi(int x);
float x_absf(float x);
int x_mini(int x, int y);
float x_minf(float x, float y);
int x_maxi(int x, int y);
float x_maxf(float x, float y);
float x_floorf(float x);
float x_ceilf(float x);
float x_ipart(float x);
float x_fpart(float x);
float x_roundf(float x);
float x_angle_to_target(float eye_x, float eye_y, float target_x, float target_y);
void x_lerp(ScePspFVector3* r, ScePspFVector3* v0, ScePspFVector3* v1, float t);
float x_magnitude(ScePspFVector3* v);
void x_normalize(ScePspFVector3* v, float mag);
float x_dotproduct(ScePspFVector3* v0, ScePspFVector3* v1);
void x_crossproduct(ScePspFVector3* r, ScePspFVector3* v0, ScePspFVector3* v1);
void x_normal(ScePspFVector3* r, ScePspFVector3* p1, ScePspFVector3* p2, ScePspFVector3* p3);
void x_translate(ScePspFVector3* v, ScePspFVector3* trans);
void x_rotatex(ScePspFVector3* v, float x);
void x_rotatey(ScePspFVector3* v, float x);
void x_rotatez(ScePspFVector3* v, float x);
void x_billboard(ScePspFVector3* r, ScePspFVector3* pos, ScePspFMatrix4* view_mat);
void x_billboard_dir(ScePspFVector3* r, ScePspFVector3* eye, ScePspFVector3* pos, ScePspFVector3* dir);
float x_ease_to_target(float cur, float target, float p, float dt);
void x_ease_to_target2(float* cur_x, float* cur_y, float target_x, float target_y, float p, float dt);
void x_ease_to_target3(ScePspFVector3* cur, ScePspFVector3* target, float p, float dt);
float x_dist2(float x1, float y1, float x2, float y2);
float x_dist3(ScePspFVector3* p1, ScePspFVector3* p2);
int x_dist_test2(float x1, float y1, float x2, float y2, float d);
int x_dist_test3(ScePspFVector3* p1, ScePspFVector3* p2, float d);
xVector3f* xVec3Set(xVector3f* a, float x, float y, float z);
xVector3f* xVec3Add(xVector3f* r, xVector3f* a, xVector3f* b);
xVector3f* xVec3Sub(xVector3f* r, xVector3f* a, xVector3f* b);
xVector3f* xVec3Mul(xVector3f* r, xVector3f* a, xVector3f* b);
xVector3f* xVec3Div(xVector3f* r, xVector3f* a, xVector3f* b);
xVector3f* xVec3Scale(xVector3f* r, xVector3f* a, float s);
xVector3f* xVec3Normalize(xVector3f* r, xVector3f* a);
float xVec3Length(xVector3f* a);
float xVec3SqLength(xVector3f* a);
xVector3f* xVec3Lerp(xVector3f* r, xVector3f* a, xVector3f* b, float t);
float xVec3Dot(xVector3f* a, xVector3f* b);
xVector3f* xVec3Cross(xVector3f* r, xVector3f* a, xVector3f* b);
xColor4f* xCol4Set(xColor4f* c, float r, float g, float b, float a);
xColor4f* xCol4Lerp(xColor4f* r, xColor4f* a, xColor4f* b, float t);
#ifdef __cplusplus
}
#endif