gd_math.h (2041B)
1 #ifndef GD_MATH_H 2 #define GD_MATH_H 3 4 #include <PR/ultratypes.h> 5 6 #include "gd_types.h" 7 #include "macros.h" 8 9 struct Row4 { 10 f32 c0, c1, c2, c3; 11 }; 12 13 struct InvMat4 { 14 struct Row4 r0, r1, r2, r3; 15 }; 16 17 enum GdRotAxis { 18 GD_X_AXIS, 19 GD_Y_AXIS, 20 GD_Z_AXIS 21 }; 22 23 // Needed for gd_math.c itself. 24 void gd_adjunct_mat4f(Mat4f *src, Mat4f *dst); 25 f32 gd_mat4f_det(Mat4f *mtx); 26 f32 gd_3x3_det(f32 r0c0, f32 r0c1, f32 r0c2, 27 f32 r1c0, f32 r1c1, f32 r1c2, 28 f32 r2c0, f32 r2c1, f32 r2c2); 29 f32 gd_2x2_det(f32 a, f32 b, f32 c, f32 d); 30 31 void gd_mat4f_lookat(Mat4f *mtx, f32 xFrom, f32 yFrom, f32 zFrom, f32 xTo, f32 yTo, f32 zTo, 32 f32 zColY, f32 yColY, f32 xColY); 33 void gd_scale_mat4f_by_vec3f(Mat4f *mtx, struct GdVec3f *vec); 34 void gd_rot_mat_about_vec(Mat4f *mtx, struct GdVec3f *vec); 35 void gd_add_vec3f_to_mat4f_offset(Mat4f *mtx, struct GdVec3f *vec); 36 void gd_create_origin_lookat(Mat4f *mtx, struct GdVec3f *vec, f32 roll); 37 f32 gd_clamp_f32(f32 a, f32 b); 38 void gd_clamp_vec3f(struct GdVec3f *vec, f32 limit); 39 void gd_rot_2d_vec(f32 deg, f32 *x, f32 *y); 40 void gd_absrot_mat4(Mat4f *mtx, s32 axisnum, f32 ang); 41 f32 gd_vec3f_magnitude(struct GdVec3f *vec); 42 s32 gd_normalize_vec3f(struct GdVec3f *vec); 43 void gd_cross_vec3f(struct GdVec3f *a, struct GdVec3f *b, struct GdVec3f *dst); 44 f32 gd_dot_vec3f(struct GdVec3f *a, struct GdVec3f *b); 45 void gd_inverse_mat4f(Mat4f *src, Mat4f *dst); 46 void gd_create_rot_mat_angular(Mat4f *mtx, struct GdVec3f *vec, f32 ang); 47 void gd_set_identity_mat4(Mat4f *mtx); 48 void gd_copy_mat4f(const Mat4f *src, Mat4f *dst); 49 void gd_rotate_and_translate_vec3f(struct GdVec3f *vec, const Mat4f *mtx); 50 void gd_mat4f_mult_vec3f(struct GdVec3f *vec, const Mat4f *mtx); 51 void gd_mult_mat4f(const Mat4f *mA, const Mat4f *mB, Mat4f *dst); 52 void gd_print_vec(UNUSED const char *prefix, const struct GdVec3f *vec); 53 void gd_print_bounding_box(UNUSED const char *prefix, const struct GdBoundingBox *p); 54 void gd_print_mtx(UNUSED const char *prefix, const Mat4f *mtx); 55 56 #endif // GD_MATH_H