2020-04-19 03:28:24 +00:00
|
|
|
#ifndef _Z64MATH_H_
|
|
|
|
#define _Z64MATH_H_
|
|
|
|
|
2020-10-03 15:22:44 +00:00
|
|
|
#include "ultra64.h"
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
#define VEC_SET(V,X,Y,Z) V.x=X;V.y=Y;V.z=Z
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
f32 x, y;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Vec2f; // size = 0x08
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
f32 x, y, z;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Vec3f; // size = 0x0C
|
2020-04-19 03:28:24 +00:00
|
|
|
|
2020-07-20 22:06:04 +00:00
|
|
|
typedef struct {
|
|
|
|
u16 x, y, z;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Vec3us; // size = 0x06
|
2020-07-20 22:06:04 +00:00
|
|
|
|
2020-04-19 03:28:24 +00:00
|
|
|
typedef struct {
|
|
|
|
s16 x, y, z;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Vec3s; // size = 0x06
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
s32 x, y, z;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Vec3i; // size = 0x0C
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Vec3s center;
|
|
|
|
s16 radius;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Sphere16; // size = 0x08
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Vec3f center;
|
|
|
|
f32 radius;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Spheref; // size = 0x10
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Vec3f normal;
|
|
|
|
f32 originDist;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Plane; // size = 0x10
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Vec3f vtx[3];
|
|
|
|
Plane plane;
|
2020-07-30 19:50:18 +00:00
|
|
|
} TriNorm; // size = 0x34
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2020-08-17 19:42:08 +00:00
|
|
|
/* 0x0000 */ s16 radius;
|
|
|
|
/* 0x0002 */ s16 height;
|
|
|
|
/* 0x0004 */ s16 yShift;
|
|
|
|
/* 0x0006 */ Vec3s pos;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Cylinder16; // size = 0x0C
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2020-10-03 15:22:44 +00:00
|
|
|
/* 0x00 */ f32 radius;
|
|
|
|
/* 0x04 */ f32 height;
|
|
|
|
/* 0x08 */ f32 yShift;
|
|
|
|
/* 0x0C */ Vec3f pos;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Cylinderf; // size = 0x18
|
2020-04-19 03:28:24 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2020-08-17 19:42:08 +00:00
|
|
|
/* 0x0000 */ Vec3f point;
|
|
|
|
/* 0x000C */ Vec3f dir;
|
|
|
|
} InfiniteLine; // size = 0x18
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
/* 0x0000 */ Vec3f a;
|
|
|
|
/* 0x000C */ Vec3f b;
|
2020-07-30 19:50:18 +00:00
|
|
|
} Linef; // size = 0x18
|
2020-04-19 03:28:24 +00:00
|
|
|
|
2020-04-30 14:49:11 +00:00
|
|
|
// Defines a point in the spherical coordinate system
|
|
|
|
typedef struct {
|
2020-10-03 15:22:44 +00:00
|
|
|
/* 0x00 */ f32 r; // radius
|
|
|
|
/* 0x04 */ s16 pitch; // polar (zenith) angle
|
|
|
|
/* 0x06 */ s16 yaw; // azimuthal angle
|
2020-07-30 19:50:18 +00:00
|
|
|
} VecSph; // size = 0x08
|
2020-04-30 14:49:11 +00:00
|
|
|
|
2020-08-17 19:42:08 +00:00
|
|
|
#define IS_ZERO(f) (fabsf(f) < 0.008f)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Trig macros
|
|
|
|
*/
|
|
|
|
#define DEGF_TO_BINANG(degreesf) ((s16)(degreesf * (65535.0f / 360.0f) + 0.5f))
|
|
|
|
#define RADF_TO_DEGF(radf) (radf * (180.0f / M_PI))
|
|
|
|
#define DEGF_TO_RADF(degf) (degf * (M_PI / 180.0f))
|
|
|
|
|
2020-04-19 03:28:24 +00:00
|
|
|
#endif
|