mm/include/sys_matrix.h

82 lines
2.3 KiB
C
Raw Normal View History

`sys_matrix` OK, documented, rename some other mathematics functions (#787) * Import data and bss, add some name options * Decomp rest of stack functions, remove RSPMatrix, split header * sys_matrix OK (thanks Tharo) Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * pragma weaks in sinf and cosf, change documentation change mcros to use 0x8000 * Rename sinf and cosf * Correct initialisation of sMtxFClear * More minor cleanup * Rename stack functions * Matrix_InsertMatrix -> Matrix_Mult * The big transpose rename * Fix MirRay_DrawReflectedBeam * Matrix_InsertTranslation -> Matrix_Translate * Matrix_Insert.Rotation_s -> Matrix_Rotate$1S + RotateY -> RotateYS * Matrix_Insert(.)Rotation_f -> Matrix_Rotate$1F * Matrix_RotateStateAroundXAxis -> Matrix_RotateXFApply Matrix_SetStateXRotation -> Matrix_RotateXFNew * Matrix_MultiplyVector3fByState -> Matrix_MultVec3f * Matrix_MultiplyVector3fXZByCurrentState -> Matrix_MultVec3fXZ * Matrix_GetStateTranslation -> Matrix_MultZero * Matrix_GetStateTranslationAndScaled(.) -> Matrix_MultVec$1 * Matrix_FromRSPMatrix -> Matrix_MtxToMtxF * Matrix_MultiplyVector3fByMatrix -> Matrix_MultVec3fExt * Matrix_TransposeXYZ -> Matrix_Transpose * Matrix_ToRSPMatrix -> Matrix_MtxFToMtx * Matrix_AppendToPolyOpaDisp -> Matrix_MtxFToNewMtx and document the conversion functions * Matrix_NormalizeXYZ -> Matrix_ReplaceRotation * Matrix_InsertRotationAroundUnitVector_f -> Matrix_RotateAxisF and S * Matrix_InsertRotation -> Matrix_RotateZYX * Document the last functions * Small cleanup * Matrix_JointPosition -> Matrix_TranslateRotateZYX * Matrix_SetStateRotationAndTranslation -> Matrix_SetTranslateRotateYXZ * func_8018219C -> Matrix_MtxFToYXZRot * func_801822C4 -> Matrix_MtxFToZYXRot * Fix files * Format * Review 1 * Renames * Fix warning in EnDragon * Format * Convert `mode` to an actual enum * Add enums, typedefs, externs to sys_matrix header * Review * One more * More review * Fix function names * Format * Fix names * Format * Review * engineer's review * Fix build * Format * Fix again Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
2022-05-26 03:24:39 +00:00
#ifndef SYS_MATRIX_H
#define SYS_MATRIX_H
#include "z64math.h"
struct GraphicsContext;
struct GameState;
typedef enum {
/* 0 */ MTXMODE_NEW, // generates a new matrix
/* 1 */ MTXMODE_APPLY // applies transformation to the current matrix
} MatrixMode;
extern Mtx gIdentityMtx;
extern MtxF gIdentityMtxF;
/* Stack operations */
void Matrix_Init(struct GameState* gameState);
void Matrix_Push(void);
void Matrix_Pop(void);
void Matrix_Get(MtxF* dest);
void Matrix_Put(MtxF* src);
MtxF* Matrix_GetCurrent(void);
/* Basic operations */
void Matrix_Mult(MtxF* matrix, MatrixMode mode);
void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode);
void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode);
void Matrix_RotateXS(s16 x, MatrixMode mode);
void Matrix_RotateXF(f32 x, MatrixMode mode);
void Matrix_RotateXFApply(f32 x);
void Matrix_RotateXFNew(f32 x);
void Matrix_RotateYS(s16 y, MatrixMode mode);
void Matrix_RotateYF(f32 y, MatrixMode mode);
void Matrix_RotateZS(s16 z, MatrixMode mode);
void Matrix_RotateZF(f32 z, MatrixMode mode);
/* Compound operations */
void Matrix_RotateZYX(s16 x, s16 y, s16 z, MatrixMode mode);
void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rot);
void Matrix_SetTranslateRotateYXZ(f32 x, f32 y, f32 z, Vec3s* rot);
/* Conversion and allocation operations */
Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest);
Mtx* Matrix_ToMtx(Mtx* dest);
Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx);
Mtx* Matrix_MtxFToNewMtx(MtxF* src, struct GraphicsContext* gfxCtx);
/* Vector operations */
void Matrix_MultVec3f(Vec3f* src, Vec3f* dest);
void Matrix_MultZero(Vec3f* dest);
void Matrix_MultVecX(f32 x, Vec3f* dest);
void Matrix_MultVecY(f32 y, Vec3f* dest);
void Matrix_MultVecZ(f32 z, Vec3f* dest);
void Matrix_MultVec3fXZ(Vec3f* src, Vec3f* dest);
/* Copy and another conversion */
void Matrix_MtxFCopy(MtxF* dest, MtxF* src);
void Matrix_MtxToMtxF(Mtx* src, MtxF* dest);
/* Miscellaneous */
void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf);
void Matrix_Transpose(MtxF* mf);
void Matrix_ReplaceRotation(MtxF* mf);
void Matrix_MtxFToYXZRot(MtxF* src, Vec3s* dest, s32 nonUniformScale);
void Matrix_MtxFToZYXRot(MtxF* src, Vec3s* dest, s32 nonUniformScale);
void Matrix_RotateAxisF(f32 angle, Vec3f* axis, MatrixMode mode);
void Matrix_RotateAxisS(s16 angle, Vec3f* axis, MatrixMode mode);
#endif