#pragma once #ifdef INTERNAL_SRC_CODE_SYS_MATH3D_C f32 Math3D_Cos(Vec3f* a, Vec3f* b); s32 Math3D_CosOut(Vec3f* a, Vec3f* b, f32* dst); s32 Math3D_CylOutsideCyl(Cylinder16* ca, Cylinder16* cb, f32* deadSpace); s32 Math3D_CylOutsideCylDist(Cylinder16* ca, Cylinder16* cb, f32* deadSpace, f32* xzDist); s32 Math3D_CylTriVsIntersect(Cylinder16* cyl, TriNorm* tri, Vec3f* intersect); s32 Math3D_CylVsLineSeg(Cylinder16* cyl, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersectA, Vec3f* intersectB); s32 Math3D_CylVsTri(Cylinder16* cyl, TriNorm* tri); void Math3D_DefPlane(Vec3f* va, Vec3f* vb, Vec3f* vc, f32* nx, f32* ny, f32* nz, f32* originDist); f32 Math3D_Dist1DSq(f32 a, f32 b); f32 Math3D_Dist2DSq(f32 x0, f32 y0, f32 x1, f32 y1); f32 Math3D_DistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* p); void Math3D_LineClosestToPoint(Linef* line, Vec3f* pos, Vec3f* closestPoint); s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect, s32 fromFront); void Math3D_LineSplitRatio(Vec3f* v0, Vec3f* v1, f32 ratio, Vec3f* ret); s32 Math3D_LineVsCube(Vec3f* min, Vec3f* max, Vec3f* a, Vec3f* b); s32 Math3D_LineVsSph(Sphere16* sphere, Linef* line); s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* closestPoint); s32 Math3D_PlaneVsPlaneVsLineClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, Vec3f* point, Vec3f* closestPoint); s32 Math3D_PointDistToLine2D(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq); s32 Math3D_PointInSquare2D(f32 upperLeftX, f32 lowerRightX, f32 upperLeftY, f32 lowerRightY, f32 x, f32 y); s32 Math3D_PointRelativeToCubeEdges(Vec3f* point, Vec3f* min, Vec3f* max); s32 Math3D_PointRelativeToCubeFaces(Vec3f* point, Vec3f* min, Vec3f* max); s32 Math3D_PointRelativeToCubeVertices(Vec3f* point, Vec3f* min, Vec3f* max); void Math3D_RotateXZPlane(Vec3f* pointOnPlane, s16 angle, f32* a, f32* c, f32* d); s32 Math3D_SphVsCylOverlapCenterDist(Sphere16* sph, Cylinder16* cyl, f32* overlapSize, f32* centerDist); s32 Math3D_SphVsCylOverlapDist(Sphere16* sph, Cylinder16* cyl, f32* overlapSize); s32 Math3D_SphVsSph(Sphere16* sphereA, Sphere16* sphereB); s32 Math3D_SphVsSphOverlap(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize); s32 Math3D_SphVsSphOverlapCenter(Sphere16* sphereA, Sphere16* sphereB, f32* overlapSize, f32* centerDist); void Math3D_SurfaceNorm(Vec3f* va, Vec3f* vb, Vec3f* vc, Vec3f* normal); s32 Math3D_TriChkLineSegParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect, f32 x0, f32 x1); s32 Math3D_TriChkLineSegParaYIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 y0, f32 y1); s32 Math3D_TriChkLineSegParaZDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 x, f32 y, f32 chkDist); s32 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect, f32 z0, f32 z1); s32 Math3D_TriChkPointParaXDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 y, f32 z, f32 chkDist); s32 Math3D_TriChkPointParaXIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect); s32 Math3D_TriChkPointParaYDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, Plane* plane, f32 z, f32 x, f32 chkDist); s32 Math3D_TriChkPointParaYIntersectDist(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist); s32 Math3D_TriChkPointParaYIntersectInsideTri(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist); s32 Math3D_TriChkPointParaYSlopedY(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 z, f32 x); s32 Math3D_TriChkPointParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect); void Math3D_TriNorm(TriNorm* tri, Vec3f* va, Vec3f* vb, Vec3f* vc); s32 Math3D_TriVsSphIntersect(Sphere16* sphere, TriNorm* tri, Vec3f* intersectPoint); s32 Math3D_TriVsTriIntersect(TriNorm* ta, TriNorm* tb, Vec3f* intersect); f32 Math3D_UDistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* p); f32 Math3D_Vec3fDistSq(Vec3f* a, Vec3f* b); f32 Math3D_Vec3fMagnitude(Vec3f* vec); f32 Math3D_Vec3fMagnitudeSq(Vec3f* vec); void Math3D_Vec3fReflect(Vec3f* vec, Vec3f* normal, Vec3f* reflVec); void Math3D_Vec3f_Cross(Vec3f* a, Vec3f* b, Vec3f* ret); f32 Math3D_Vec3f_DistXYZ(Vec3f* a, Vec3f* b); s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y); s32 Math3D_XZInSphere(Sphere16* sphere, f32 x, f32 z); s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z); #else f32 Math3D_Cos(struct Vec3f* a, struct Vec3f* b); s32 Math3D_CosOut(struct Vec3f* a, struct Vec3f* b, f32* dst); s32 Math3D_CylOutsideCyl(struct Cylinder16* ca, struct Cylinder16* cb, f32* deadSpace); s32 Math3D_CylOutsideCylDist(struct Cylinder16* ca, struct Cylinder16* cb, f32* deadSpace, f32* xzDist); s32 Math3D_CylTriVsIntersect(struct Cylinder16* cyl, struct TriNorm* tri, struct Vec3f* intersect); s32 Math3D_CylVsLineSeg(struct Cylinder16* cyl, struct Vec3f* linePointA, struct Vec3f* linePointB, struct Vec3f* intersectA, struct Vec3f* intersectB); s32 Math3D_CylVsTri(struct Cylinder16* cyl, struct TriNorm* tri); void Math3D_DefPlane(struct Vec3f* va, struct Vec3f* vb, struct Vec3f* vc, f32* nx, f32* ny, f32* nz, f32* originDist); f32 Math3D_Dist1DSq(f32 a, f32 b); f32 Math3D_Dist2DSq(f32 x0, f32 y0, f32 x1, f32 y1); f32 Math3D_DistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, struct Vec3f* p); void Math3D_LineClosestToPoint(struct Linef* line, struct Vec3f* pos, struct Vec3f* closestPoint); s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, struct Vec3f* linePointA, struct Vec3f* linePointB, struct Vec3f* intersect, s32 fromFront); void Math3D_LineSplitRatio(struct Vec3f* v0, struct Vec3f* v1, f32 ratio, struct Vec3f* ret); s32 Math3D_LineVsCube(struct Vec3f* min, struct Vec3f* max, struct Vec3f* a, struct Vec3f* b); s32 Math3D_LineVsSph(struct Sphere16* sphere, struct Linef* line); s32 Math3D_PlaneVsLineSegClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, struct Vec3f* linePointA, struct Vec3f* linePointB, struct Vec3f* closestPoint); s32 Math3D_PlaneVsPlaneVsLineClosestPoint(f32 planeAA, f32 planeAB, f32 planeAC, f32 planeADist, f32 planeBA, f32 planeBB, f32 planeBC, f32 planeBDist, struct Vec3f* point, struct Vec3f* closestPoint); s32 Math3D_PointDistToLine2D(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq); s32 Math3D_PointInSquare2D(f32 upperLeftX, f32 lowerRightX, f32 upperLeftY, f32 lowerRightY, f32 x, f32 y); s32 Math3D_PointRelativeToCubeEdges(struct Vec3f* point, struct Vec3f* min, struct Vec3f* max); s32 Math3D_PointRelativeToCubeFaces(struct Vec3f* point, struct Vec3f* min, struct Vec3f* max); s32 Math3D_PointRelativeToCubeVertices(struct Vec3f* point, struct Vec3f* min, struct Vec3f* max); void Math3D_RotateXZPlane(struct Vec3f* pointOnPlane, s16 angle, f32* a, f32* c, f32* d); s32 Math3D_SphVsCylOverlapCenterDist(struct Sphere16* sph, struct Cylinder16* cyl, f32* overlapSize, f32* centerDist); s32 Math3D_SphVsCylOverlapDist(struct Sphere16* sph, struct Cylinder16* cyl, f32* overlapSize); s32 Math3D_SphVsSph(struct Sphere16* sphereA, struct Sphere16* sphereB); s32 Math3D_SphVsSphOverlap(struct Sphere16* sphereA, struct Sphere16* sphereB, f32* overlapSize); s32 Math3D_SphVsSphOverlapCenter(struct Sphere16* sphereA, struct Sphere16* sphereB, f32* overlapSize, f32* centerDist); void Math3D_SurfaceNorm(struct Vec3f* va, struct Vec3f* vb, struct Vec3f* vc, struct Vec3f* normal); s32 Math3D_TriChkLineSegParaXIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect, f32 x0, f32 x1); s32 Math3D_TriChkLineSegParaYIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 y0, f32 y1); s32 Math3D_TriChkLineSegParaZDist(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, struct Plane* plane, f32 x, f32 y, f32 chkDist); s32 Math3D_TriChkLineSegParaZIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect, f32 z0, f32 z1); s32 Math3D_TriChkPointParaXDist(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, struct Plane* plane, f32 y, f32 z, f32 chkDist); s32 Math3D_TriChkPointParaXIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 y, f32 z, f32* xIntersect); s32 Math3D_TriChkPointParaYDist(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, struct Plane* plane, f32 z, f32 x, f32 chkDist); s32 Math3D_TriChkPointParaYIntersectDist(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist); s32 Math3D_TriChkPointParaYIntersectInsideTri(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 z, f32 x, f32* yIntersect, f32 chkDist); s32 Math3D_TriChkPointParaYSlopedY(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 z, f32 x); s32 Math3D_TriChkPointParaZIntersect(struct Vec3f* v0, struct Vec3f* v1, struct Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect); void Math3D_TriNorm(struct TriNorm* tri, struct Vec3f* va, struct Vec3f* vb, struct Vec3f* vc); s32 Math3D_TriVsSphIntersect(struct Sphere16* sphere, struct TriNorm* tri, struct Vec3f* intersectPoint); s32 Math3D_TriVsTriIntersect(struct TriNorm* ta, struct TriNorm* tb, struct Vec3f* intersect); f32 Math3D_UDistPlaneToPos(f32 nx, f32 ny, f32 nz, f32 originDist, struct Vec3f* p); f32 Math3D_Vec3fDistSq(struct Vec3f* a, struct Vec3f* b); f32 Math3D_Vec3fMagnitude(struct Vec3f* vec); f32 Math3D_Vec3fMagnitudeSq(struct Vec3f* vec); void Math3D_Vec3fReflect(struct Vec3f* vec, struct Vec3f* normal, struct Vec3f* reflVec); void Math3D_Vec3f_Cross(struct Vec3f* a, struct Vec3f* b, struct Vec3f* ret); f32 Math3D_Vec3f_DistXYZ(struct Vec3f* a, struct Vec3f* b); s32 Math3D_XYInSphere(struct Sphere16* sphere, f32 x, f32 y); s32 Math3D_XZInSphere(struct Sphere16* sphere, f32 x, f32 z); s32 Math3D_YZInSphere(struct Sphere16* sphere, f32 y, f32 z); #endif