diff options
Diffstat (limited to 'src/math/math.h')
-rw-r--r-- | src/math/math.h | 204 |
1 files changed, 102 insertions, 102 deletions
diff --git a/src/math/math.h b/src/math/math.h index a69dabe..8f59137 100644 --- a/src/math/math.h +++ b/src/math/math.h @@ -133,17 +133,17 @@ typedef union { /* Vec */ /************************************************************************/ -void vec2_scale(Vec2* v, float k, Vec2* out); -void vec2_plus(Vec2* v1, Vec2* v2, Vec2* out); -void vec2_offset(Vec2* v, float offset, Vec2* out); -void vec2_rotate(Vec2* v, float angle, Vec2* out); +void internal_vec2_scale(Vec2* v, float k, Vec2* out); +void internal_vec2_plus(Vec2* v1, Vec2* v2, Vec2* out); +void internal_vec2_offset(Vec2* v, float offset, Vec2* out); +void internal_vec2_rotate(Vec2* v, float angle, Vec2* out); -float vec2_dot(Vec2* v1, Vec2* v2); +float internal_vec2_dot(Vec2* v1, Vec2* v2); -void vec2_tostring(Vec2* v, char buf[]); -void vec2_print(Vec2* v); +void internal_vec2_tostring(Vec2* v, char buf[]); +void internal_vec2_print(Vec2* v); -#define vec3_xy(v) (v->xy) +#define internal_vec3_xy(v) (v->xy) extern Vec3 vec3forward; /*(0,0,1)*/ extern Vec3 vec3up; /*(0,1,0)*/ @@ -156,41 +156,41 @@ extern Vec4 vec4zero; /*(0,0,0)*/ #define zerovec3 {0, 0, 0} #define zerovec4 {0, 0, 0, 0} -void vec3_tostring(Vec3* v, char buf[]); -void vec3_print(Vec3* v); +void internal_vec3_tostring(Vec3* v, char buf[]); +void internal_vec3_print(Vec3* v); -Vec3 vec3_make(float x, float y, float z); -float vec3_intersection(Vec3* v1, Vec3* v2); /*夹角*/ -void vec3_projection(Vec3* v1, Vec3* v2, Vec3* out);/*v1在v2上的投影*/ -void vec3_scale(Vec3* v, float k, Vec3* out); -void vec3_scale3(Vec3* v, Vec3* scalar, Vec3* out); -void vec3_plus(Vec3* v1, Vec3* v2, Vec3* out); -void vec3_offset(Vec3* v, float offset, Vec3* out); -void vec3_normalize(Vec3* v, Vec3* out); -void vec3_vec4(float w, Vec4* out); +Vec3 internal_vec3_make(float x, float y, float z); +float internal_vec3_intersection(Vec3* v1, Vec3* v2); /*夹角*/ +void internal_vec3_projection(Vec3* v1, Vec3* v2, Vec3* out);/*v1在v2上的投影*/ +void internal_vec3_scale(Vec3* v, float k, Vec3* out); +void internal_vec3_scale3(Vec3* v, Vec3* scalar, Vec3* out); +void internal_vec3_plus(Vec3* v1, Vec3* v2, Vec3* out); +void internal_vec3_offset(Vec3* v, float offset, Vec3* out); +void internal_vec3_normalize(Vec3* v, Vec3* out); +void internal_vec3_vec4(float w, Vec4* out); -void vec3_minus(Vec3* v1, Vec3* v2, Vec3* out); -float vec3_dot(Vec3* v1, Vec3* v2); -void vec3_cross(Vec3* v1, Vec3* v2, Vec3* out); -void vec3_multiply(Vec3* v1, Vec3* v2, Quat* out);// 向量的乘法,st=sxt-s*t,结果是一个四元数 +void internal_vec3_minus(Vec3* v1, Vec3* v2, Vec3* out); +float internal_vec3_dot(Vec3* v1, Vec3* v2); +void internal_vec3_cross(Vec3* v1, Vec3* v2, Vec3* out); +void internal_vec3_multiply(Vec3* v1, Vec3* v2, Quat* out);// 向量的乘法,st=sxt-s*t,结果是一个四元数 -float vec3_magnitude(Vec3* v1); -float vec3_magnitude2(Vec3* v1); +float internal_vec3_magnitude(Vec3* v1); +float internal_vec3_magnitude2(Vec3* v1); -void vec3_lerp(Vec3* v1, Vec3* v2, float t, Vec3* out); -void vec3_slerp(Vec3* v1, Vec3* v2, float t, Vec3* out); +void internal_vec3_lerp(Vec3* v1, Vec3* v2, float t, Vec3* out); +void internal_vec3_slerp(Vec3* v1, Vec3* v2, float t, Vec3* out); -void vec4_dividew(Vec4* v, Vec3* out); -void vec4_dividewnoz(Vec4* v, Vec4* out); +void internal_vec4_dividew(Vec4* v, Vec3* out); +void internal_vec4_dividewnoz(Vec4* v, Vec4* out); -void vec4_tostring(Vec4* v, char buf[]); -void vec4_print(Vec4* v); +void internal_vec4_tostring(Vec4* v, char buf[]); +void internal_vec4_print(Vec4* v); -void vec4_lerp(Vec4* a, Vec4* b, float t, Vec4* out); +void internal_vec4_lerp(Vec4* a, Vec4* b, float t, Vec4* out); -void vec4_scale(Vec4* v, float t, Vec4* out); +void internal_vec4_scale(Vec4* v, float t, Vec4* out); -void vec4_add(Vec4* v1, Vec4* v2, Vec4* out); +void internal_vec4_add(Vec4* v1, Vec4* v2, Vec4* out); /************************************************************************/ @@ -199,57 +199,57 @@ void vec4_add(Vec4* v1, Vec4* v2, Vec4* out); extern Mat4 mat4identity; -void mat4_tostring(Mat4* m, char str[]); -void mat4_print(Mat4* m); +void internal_mat4_tostring(Mat4* m, char str[]); +void internal_mat4_print(Mat4* m); -void mat4_zero(Mat4* out); -void mat4_setidentity(Mat4* out); -void mat4_setfrustum(float l, float r, float b, float t, float n, float f, Mat4* out); -void mat4_setperspective(float fov, float aspect, float near, float far, Mat4* out); -void mat4_setortho(float l, float r, float b, float t, float n, float f, Mat4* out); -void mat4_setscale(float kx, float ky, float kz, Mat4* out); -void mat4_setposition(float x, float y, float z, Mat4* out); -void mat4_setrotatez(float angle, Mat4* out); -void mat4_setrotatex(float angle, Mat4* out); -void mat4_setrotatey(float angle, Mat4* out); -void mat4_setrotate(float angleX, float angleY, float angleZ, Mat4* out);/*RyRxRz*/ -void mat4_setaxisangle(Vec3* axis, float angle, Mat4* out); +void internal_mat4_zero(Mat4* out); +void internal_mat4_setidentity(Mat4* out); +void internal_mat4_setfrustum(float l, float r, float b, float t, float n, float f, Mat4* out); +void internal_mat4_setperspective(float fov, float aspect, float near, float far, Mat4* out); +void internal_mat4_setortho(float l, float r, float b, float t, float n, float f, Mat4* out); +void internal_mat4_setscale(float kx, float ky, float kz, Mat4* out); +void internal_mat4_setposition(float x, float y, float z, Mat4* out); +void internal_mat4_setrotatez(float angle, Mat4* out); +void internal_mat4_setrotatex(float angle, Mat4* out); +void internal_mat4_setrotatey(float angle, Mat4* out); +void internal_mat4_setrotate(float angleX, float angleY, float angleZ, Mat4* out);/*RyRxRz*/ +void internal_mat4_setaxisangle(Vec3* axis, float angle, Mat4* out); -bool mat4_setlookrotation(Vec3* view, Vec3* up, Mat4* out); -void mat4_setorthonormalbias(Vec3* x, Vec3* y, Vec3* z, Mat4* out); /*正交的三个轴*/ +bool internal_mat4_setlookrotation(Vec3* view, Vec3* up, Mat4* out); +void internal_mat4_setorthonormalbias(Vec3* x, Vec3* y, Vec3* z, Mat4* out); /*正交的三个轴*/ -void mat4_orthogonalize(Mat4* in, Mat4* out); /*解决矩阵蠕变,对左上角3x3矩阵进行正交化,结果是右手系的正交矩阵*/ -bool mat4_isorthogonal(Mat4* m); /*判断是不是正交矩阵*/ -bool mat4_isidentity(Mat4* m); +void internal_mat4_orthogonalize(Mat4* in, Mat4* out); /*解决矩阵蠕变,对左上角3x3矩阵进行正交化,结果是右手系的正交矩阵*/ +bool internal_mat4_isorthogonal(Mat4* m); /*判断是不是正交矩阵*/ +bool internal_mat4_isidentity(Mat4* m); -void mat4_settr(Vec3* pos, Quat* rot, Mat4* out); /*用旋转和平移初始化mat4*/ -void mat4_settrs(Vec3* pos, Quat* rot, Vec3* scale, Mat4* out); -void mat4_settrinverse(Vec3* pos, Quat* rot, Mat4* out); +void internal_mat4_settr(Vec3* pos, Quat* rot, Mat4* out); /*用旋转和平移初始化mat4*/ +void internal_mat4_settrs(Vec3* pos, Quat* rot, Vec3* scale, Mat4* out); +void internal_mat4_settrinverse(Vec3* pos, Quat* rot, Mat4* out); -void mat4_multiply(Mat4* m1, Mat4* m2, Mat4* out); /* m1的行乘m2的列,意义是用m1变换m2 */ +void internal_mat4_multiply(Mat4* m1, Mat4* m2, Mat4* out); /* m1的行乘m2的列,意义是用m1变换m2 */ -void mat4_transpose(Mat4* m, Mat4* out); +void internal_mat4_transpose(Mat4* m, Mat4* out); -void mat4_scale(Mat4* m, Vec3* scale, Mat4* out);/* 后乘post-multiply scale */ -void mat4_translate(Mat4* m, Vec3* pos, Mat4* out); /* 后乘post-multiply translate */ -void mat4_rotate(Mat4*m, float angle, Vec3* rot, Mat4* out);/*后乘绕任意轴向量旋转矩阵*/ +void internal_mat4_scale(Mat4* m, Vec3* scale, Mat4* out);/* 后乘post-multiply scale */ +void internal_mat4_translate(Mat4* m, Vec3* pos, Mat4* out); /* 后乘post-multiply translate */ +void internal_mat4_rotate(Mat4*m, float angle, Vec3* rot, Mat4* out);/*后乘绕任意轴向量旋转矩阵*/ -bool mat4_invertfull(Mat4* in, Mat4* out); /* 并不是所有矩阵都能求逆 */ -bool mat4_invertgeneral3d(Mat4* in, Mat4* out); /* 对scale rotate translate求逆 */ -void mat4_invertscale(Mat4* scale, Mat4* out); /* 对缩放矩阵求逆 */ -void mat4_invertrot(Mat4* rot, Mat4* out); /* 对旋转矩阵求逆 */ -void mat4_invertpos(Mat4* pos, Mat4* out); /* 对平移矩阵求逆 */ +bool internal_mat4_invertfull(Mat4* in, Mat4* out); /* 并不是所有矩阵都能求逆 */ +bool internal_mat4_invertgeneral3d(Mat4* in, Mat4* out); /* 对scale rotate translate求逆 */ +void internal_mat4_invertscale(Mat4* scale, Mat4* out); /* 对缩放矩阵求逆 */ +void internal_mat4_invertrot(Mat4* rot, Mat4* out); /* 对旋转矩阵求逆 */ +void internal_mat4_invertpos(Mat4* pos, Mat4* out); /* 对平移矩阵求逆 */ -void mat4_decomposetrs(Mat4* src, Vec3* pos, Quat* quat, Vec3* scale); /*分解trs矩阵*/ +void internal_mat4_decomposetrs(Mat4* src, Vec3* pos, Quat* quat, Vec3* scale); /*分解trs矩阵*/ -void mat4_mulvec4(Mat4* m, Vec4* v, Vec4* out); -void mat4_mulvec3(Mat4* m, Vec3* v, Vec3* out); +void internal_mat4_mulvec4(Mat4* m, Vec4* v, Vec4* out); +void internal_mat4_mulvec3(Mat4* m, Vec3* v, Vec3* out); -bool mat4_toeuler(Mat4* in, Euler* out); /* 计算YXZ旋转矩阵的欧拉角 */ -void mat4_toquat(Mat4* in, Quat* out); /*in是正交矩阵*/ +bool internal_mat4_toeuler(Mat4* in, Euler* out); /* 计算YXZ旋转矩阵的欧拉角 */ +void internal_mat4_toquat(Mat4* in, Quat* out); /*in是正交矩阵*/ #define ROWMAT(A, ...)\ -Mat4 A={__VA_ARGS__};mat4_transpose(&A, &A); +Mat4 A={__VA_ARGS__};internal_mat4_transpose(&A, &A); void mat3_multvec3(Mat3* m, Vec3* v, Vec3* out); void mat23_applytovec3(Mat23* m, Vec3* v, Vec2* out); @@ -259,47 +259,47 @@ void mat43_applytovec3(Mat43* m, Vec3* v, Vec4* out); /* Quat */ /************************************************************************/ -void quat_tostring(Quat* q, char str[]); -void quat_print(Quat* q); +void internal_quat_tostring(Quat* q, char str[]); +void internal_quat_print(Quat* q); -Quat quat_make(float rx, float ry, float rz); +Quat internal_quat_make(float rx, float ry, float rz); -void euler_toquat(Euler* e, Quat* out); -void euler_deg2rad(Euler* in, Euler* out); -void euler_rad2deg(Euler* in, Euler* out); +void internal_euler_toquat(Euler* e, Quat* out); +void internal_euler_deg2rad(Euler* in, Euler* out); +void internal_euler_rad2deg(Euler* in, Euler* out); -void euler_tostring(Euler* v, char buf[]); -void euler_print(Euler* v); +void internal_euler_tostring(Euler* v, char buf[]); +void internal_euler_print(Euler* v); -void quat_fromaxisangle(Vec3* axis, float angle, Quat* out); /*轴角转四元数*/ -void quat_fromeuler(Euler* euler, Quat* out); /*按照zxy顺序*/ +void internal_quat_fromaxisangle(Vec3* axis, float angle, Quat* out); /*轴角转四元数*/ +void internal_quat_fromeuler(Euler* euler, Quat* out); /*按照zxy顺序*/ -void quat_tomat4(Quat* q, Mat4* out); -void quat_toeuler(Quat*q, Euler* out); +void internal_quat_tomat4(Quat* q, Mat4* out); +void internal_quat_toeuler(Quat*q, Euler* out); -void quat_normalize(Quat* q, Quat* out); /*解决蠕变,保持四元数合法*/ +void internal_quat_normalize(Quat* q, Quat* out); /*解决蠕变,保持四元数合法*/ -void quat_scale(Quat* q, float scale, Quat* out); -void quat_rotate(); +void internal_quat_scale(Quat* q, float scale, Quat* out); +void internal_quat_rotate(); -void quat_minus(Quat* q1, Quat* q2, Quat* out); -void quat_slerp(Quat* start, Quat* end, float t, Quat* out); -void quat_lerp(Quat* start, Quat* end, float t, Quat* out); -void quat_translate(Quat* q, Vec4* v, Vec4* out); -void quat_invert(Quat* q, Quat* out); -float quat_dot(Quat* q1, Quat* q2); -void quat_multiply(Quat* q1, Quat* q2, Quat* out); -void quat_devide(Quat* q, float k, Quat* out); -void quat_negtive(Quat* in, Quat* out); -bool quat_isidentity(Quat* q); +void internal_quat_minus(Quat* q1, Quat* q2, Quat* out); +void internal_quat_slerp(Quat* start, Quat* end, float t, Quat* out); +void internal_quat_lerp(Quat* start, Quat* end, float t, Quat* out); +void internal_quat_translate(Quat* q, Vec4* v, Vec4* out); +void internal_quat_invert(Quat* q, Quat* out); +float internal_quat_dot(Quat* q1, Quat* q2); +void internal_quat_multiply(Quat* q1, Quat* q2, Quat* out); +void internal_quat_devide(Quat* q, float k, Quat* out); +void internal_quat_negtive(Quat* in, Quat* out); +bool internal_quat_isidentity(Quat* q); -void quat_applytovec3(Quat* q, Vec3* v, Vec3* out); /*用四元数直接旋转向量*/ +void internal_quat_applytovec3(Quat* q, Vec3* v, Vec3* out); /*用四元数直接旋转向量*/ -void quat_conjugate(Quat* in, Quat* out); +void internal_quat_conjugate(Quat* in, Quat* out); -bool quat_setlookrotation(Vec3* view, Vec3* up, Quat* out); +bool internal_quat_setlookrotation(Vec3* view, Vec3* up, Quat* out); -float quat_magnitude(Quat* q); -float quat_magnitude2(Quat* q); +float internal_quat_magnitude(Quat* q); +float internal_quat_magnitude2(Quat* q); #endif
\ No newline at end of file |