//XMATH - [2020-06-22 11:41:46]
#ifndef _XMATH_H_
#define _XMATH_H_

#include "CFTTVector32.h"
#include "CFTTMatrix32.h"

/*
001F2368 XMATH_ArcTan(int,int)
001F2400 XMATH_RaySphereTest(TPoint3D *,int,TPoint3D *,TPoint3D *,int)
001F248E XMATH_DotProduct(TPoint3D *,TPoint3D *)
001F24A8 XMATH_TendAngle(int,int)
001F24F4 XMATH_CalcSqrt(uint)
001F251C XMATH_CalcSqrt(uint64_t)
001F2586 XMATH_Normalize(TPoint3D *,int)
001F25F2 XMATH_Normalize(TPoint *,int)
001F2644 XMATH_Normalize(TPoint3D,int)
001F26B0 XMATH_Normalize2D(TPoint3D,int)
001F2700 XMATH_Normalize(TPoint,int)
001F2756 XMATH_Normalize(TPointF *,float)
001F27AE XMATH_Cross(TPoint3D *,TPoint3D *,TPoint3D *)
001F2802 XMATH_Subtract(TPoint3D *,TPoint3D *,TPoint3D *)
001F2824 XMATH_Add(TPoint3D *,TPoint3D *,TPoint3D *)
001F2842 XMATH_Scale(TPoint3D *,int,TPoint3D *)
001F2856 XMATH_IsDotPositive(TPoint *,TPoint *)
001F2874 XMATH_IsSimilarDirection(TPoint *,TPoint *)
001F28B6 XMATH_ClipVectorX(TPoint *,TPoint *,int)
001F2904 XMATH_ClipVectorY(TPoint *,TPoint *,int)
001F2952 XMATH_ClipVectorX(TPoint3D *,TPoint3D *,int)
001F29CA XMATH_ClipVectorY(TPoint3D *,TPoint3D *,int)
001F2A44 XMATH_LineIntersect(TPoint const*,TPoint const*,TPoint const*,TPoint*,int *)
001F2B3C XMATH_LineIntersect3D(TPoint3D const*,TPoint3D const*,TPoint3D const*,TPoint3D*,int *)
001F2CA4 XMATH_DistPointToLineF(TPointF3D,TPointF3D,TPointF3D,TPointF3D*,float *)
001F2D80 XMATH_Mag3D(TPointF3D const*)
001F2DC2 XMATH_LineLineIntersect(TPoint const*,TPoint const*,TPoint const*,TPoint const*,TPoint*)
001F2F20 XMATH_LineLineDistance(TPoint3D const*,TPoint3D const*,TPoint3D const*,TPoint3D const*,int *,int *)
001F322C XMATH_Clamp64(long long,long long,long long)
001F3274 XMATH_Mag3D(TPoint3D const*)
001F328A XMATH_Mag(TPoint const*)
001F329E XMATH_Mag(TPointF const*)
001F32D8 XMATH_Mag2D(TPoint3D const*)
001F32DC XMATH_Project(int,int)
001F3398 XMATH_PointProject(TPoint,int,int)
001F33CE XMATH_PointProject(TPoint3D,int,int)
001F3404 XMATH_Squeeze(TPoint3D *,TPoint3D *,int)
001F3490 XMATH_Distance3D(TPoint3D const*,TPoint3D const*)
001F34BA XMATH_BlendAngle(int,int,int)
001F3500 XMATH_InterpolateClampColor(float,float,float,uint,uint)
001F363C XMATH_InterpolateClampFloat(float,float,float,float,float)
001F36B0 XMATH_BitSum(uint)
001F36CA XMATH_QuatNormalize(TQuat *,TQuat *)
001F372C XMATH_QuatMultiply(TQuat *,TQuat *,TQuat *)
001F37C8 XMATH_EulerToQuat(int,int,int,TQuat *)
001F38B0 XMATH_SetQuatIdentity(TQuat *)
001F38D0 XMATH_RotatePoint(TPoint *,int)
001F3934 XMATH_QuatRotateEuler(TQuat *,TPoint3D *)
001F396E XMATH_QuatSlerp(TQuat *,TQuat *,TQuat *,int)
001F3B66 XMATH_QuatBlend(TQuat *,TQuat *,TQuat *,int)
001F3B7A XMATH_EaseInOut(int,int,int)
001F3B9E XMATH_Power(int,int)
001F3BAE XMATH_ClampAngle(int,int,int)
001F3BD4 XMATH_IsPowerOfTwo(int)
001F3BE8 XMATH_Clamp(int,int,int)
001F3BF8 XMATH_Clampu8(uchar,uchar,uchar)
001F3C08 XMATH_ClampFloat(float,float,float)
001F3C36 XMATH_WrapFloat(float,float,float)
001F3C80 XMATH_Wrap(int,int,int)
001F3C98 XMATH_WrapLimit(int,int,int)
001F3CAA XMATH_MagSq(TPoint const*)
001F3CC8 XMATH_ClampMag(TPoint *,int)
001F3CF2 XMATH_ClampMagMin(TPoint *,int)
001F3D12 XMATH_DistanceSq(TPoint const*,TPoint const*)
001F3D38 XMATH_Distance3DSq(TPoint3D const*,TPoint3D const*)
001F3D78 XMATH_Distance(TPoint const*,TPoint const*)
001F3D94 XMATH_Distance3DF(TPointF3D *,TPointF3D *)
001F3DD4 XMATH_Interpolate(int,int,int,int,int)
001F3DF0 XMATH_InterpAngle(int,int,int,int,int)
001F3E18 XMATH_InterpolateFloat(float,float,float,float,float)
001F3E4A XMATH_InterpolateClamp(int,int,int,int,int)
001F3E92 XMATH_SinInterpolateClamp(int,int,int,int,int)
001F3EB8 XMATH_SinInterpolateClampFloat(float,float,float,float,float)
001F3F20 XMATH_InterpolatePos(TPoint *,int,int,int,TPoint,TPoint)
001F3F74 XMATH_InterpolatePos3D(TPoint3D *,int,int,int,TPoint3D,TPoint3D)
001F3FFC XMATH_SinInterpolatePos3D(TPoint3D *,int,int,int,TPoint3D,TPoint3D)
001F4084 XMATH_SetupRectI(TRectI *,int,int,int,int)
001F408E XMATH_SetupRect(TRect *,float,float,float,float)
001F409C XMATH_WrapToBounds(int,int,int)
001F40AE XMATH_RectOverlap(TRect,float,float,float,float)
001F4138 XMATH_RectOverlap(TRect,TRect)
001F41D4 XMATH_Dot_F(TPointF3D *,TPointF3D *)
001F41FE XMATH_DotProduct(TPoint *,TPoint *)
001F4214 XMATH_RGBDiff(uint,uint)
001F424C XMATH_MaxF(float,float)
001F4268 XMATH_MinF(float,float)
001F4284 XMATH_IsCrossingLine(int,int,int)
001F42AA XMATH_IsCrossingLine2D(TPoint,TPoint,TPoint,TPoint)
001F432C XMATH_IsCrossingLineOneWay(int,int,int,int)
001F4344 XMATH_IsStayingOneSideOf(int,int,int,int)
001F435C XMATH_IsStayingBetween(int,int,int,int)
001F4376 XMATH_IsPwrTwo(int)
001F438A XMATH_GetCurvePosF(TPointF,TPointF,TPointF,float)
001F43E0 XMATH_CreateRandomIndexArray(int *,int)
001F4416 XMATH_ShuffleArray(ushort *,int)
001F4440 XMATH_CountNumDigits(int)
001F445C XMATH_RoundToNearest(int,int)
001F4476 XMATH_RoundFloatToNearestInt(float)
001F449E XMATH_CatmullRom(CFTTVector32 const&,CFTTVector32 const&,CFTTVector32 const&,CFTTVector32 const&,float)
001F459E XMATH_StringToYardInt(char const*)
001F4638 XMATH_ClipPathBounds(TPoint3D *,TPoint3D *,int,int,int,int)
001F4680 XMATH_ClipPathBounds(TPoint *,TPoint *,int,int,int,int)
*/

struct TRect {
  float fx_0;
  float fy_4;
  float fWidth_8;
  float fHeight_C;

  TRect &operator=(const TRect &other) {
    memcpy(this, &other, sizeof(TRect));
    //fx_0 = o.fx_0;
    //fy_4 = o.fy_4;
    //fWidth_8 = o.fWidth_8;
    //fHeight_C = o.fHeight_C;
    return *this;
  };
};

struct TRectI {
  int ix_0;
  int iy_4;
  int iWidth_8;
  int iHeight_C;

  TRectI &operator=(const TRectI &o) {
    ix_0 = o.ix_0;
    iy_4 = o.iy_4;
    iWidth_8 = o.iWidth_8;
    iHeight_C = o.iHeight_C;
    return *this;
  };
};

//struct TQuat {
// int field_0;
// int field_4;
// int field_8;
// int field_C;
//};

struct TQuat {
  int d1_0;
  int d2_4;
  int d3_8;
  int d4_C;
};

//001F2368
ushort XMATH_ArcTan(int, int);

//001F2400
float XMATH_RaySphereTest(TPoint3D *, int, TPoint3D *, TPoint3D *, int);

//001F248E
float XMATH_DotProduct(TPoint3D *, TPoint3D *);

//001F24A8
float XMATH_TendAngle(int, int);

//001F24F4
uint XMATH_CalcSqrt(uint);

//001F251C
uint64_t XMATH_CalcSqrt(uint64_t d);

//001F2586
void XMATH_Normalize(TPoint3D *, int);

//001F25F2
void XMATH_Normalize(TPoint *, int);

//001F2644
TPoint3D XMATH_Normalize(TPoint3D, int);

//001F26B0
TPoint3D XMATH_Normalize2D(TPoint3D, int);

//001F2700
TPoint XMATH_Normalize(TPoint, int);

//001F2756
float XMATH_Normalize(TPointF *, float);

//001F27AE
float XMATH_Cross(TPoint3D *, TPoint3D *, TPoint3D *);

//001F2802
float XMATH_Subtract(TPoint3D *, TPoint3D *, TPoint3D *);

//001F2824
float XMATH_Add(TPoint3D *, TPoint3D *, TPoint3D *);

//001F2842
float XMATH_Scale(TPoint3D *, int, TPoint3D *);

//001F2856
float XMATH_IsDotPositive(TPoint *, TPoint *);

//001F2874
float XMATH_IsSimilarDirection(TPoint *, TPoint *);

//001F28B6
float XMATH_ClipVectorX(TPoint *, TPoint *, int);

//001F2904
void XMATH_ClipVectorY(TPoint *, TPoint *, int);

//001F2952
void XMATH_ClipVectorX(TPoint3D *, TPoint3D *, int);

//001F29CA
void XMATH_ClipVectorY(TPoint3D *, TPoint3D *, int);

//001F2A44
void XMATH_LineIntersect(TPoint const *, TPoint const *, TPoint const *, TPoint *, int *);

//001F2B3C
float XMATH_LineIntersect3D(TPoint3D const *, TPoint3D const *, TPoint3D const *, TPoint3D *, int *);

//001F2CA4
float XMATH_DistPointToLineF(TPointF3D, TPointF3D, TPointF3D, TPointF3D *, float *);

//001F2D80
float XMATH_Mag3D(TPointF3D const *);

//001F2DC2
float XMATH_LineLineIntersect(TPoint const *, TPoint const *, TPoint const *, TPoint const *, TPoint *);

//001F2F20
int XMATH_LineLineDistance(TPoint3D const *, TPoint3D const *, TPoint3D const *, TPoint3D const *, int *, int *);

//001F322C
float XMATH_Clamp64(long long, long long, long long);

//001F3274
uint32_t XMATH_Mag3D(TPoint3D const *);

//001F328A
uint64_t XMATH_Mag(TPoint const *);

//001F329E
float XMATH_Mag(TPointF const *);

//001F32D8
uint64_t XMATH_Mag2D(TPoint3D const *);

//001F32DC
TPoint XMATH_Project(int, int);

//001F3398
TPoint XMATH_PointProject(TPoint, int, int);

//001F33CE
TPoint3D XMATH_PointProject(TPoint3D, int, int);

//001F3404
float XMATH_Squeeze(TPoint3D *, TPoint3D *, int);

//001F3490
uint32_t XMATH_Distance3D(TPoint3D const *, TPoint3D const *);

//001F34BA
float XMATH_BlendAngle(int, int, int);

//001F3500
float XMATH_InterpolateClampColor(float, float, float, uint, uint);

//001F363C
float XMATH_InterpolateClampFloat(float, float, float, float, float);

//001F36B0
uint XMATH_BitSum(uint);

//001F36CA
void XMATH_QuatNormalize(TQuat *, TQuat *);

//001F372C
void XMATH_QuatMultiply(TQuat *, TQuat *, TQuat *);

//001F37C8
void XMATH_EulerToQuat(int, int, int, TQuat *);

//001F38B0
float XMATH_SetQuatIdentity(TQuat *);

//001F38D0
TPoint XMATH_RotatePoint(TPoint *, int);

//001F3934
void XMATH_QuatRotateEuler(TQuat *, TPoint3D *);

//001F396E
void XMATH_QuatSlerp(TQuat *, TQuat *, TQuat *, int);

//001F3B66
void XMATH_QuatBlend(TQuat *, TQuat *, TQuat *, int);

//001F3B7A
float XMATH_EaseInOut(int, int, int);

//001F3B9E
float XMATH_Power(int, int);

//001F3BAE
float XMATH_ClampAngle(int, int, int);

//001F3BD4
float XMATH_IsPowerOfTwo(int);

//001F3BE8
int XMATH_Clamp(int, int, int);

//001F3BF8
float XMATH_Clampu8(uchar, uchar, uchar);

//001F3C08
float XMATH_ClampFloat(float, float, float);

//001F3C36
float XMATH_WrapFloat(float, float, float);

//001F3C80
float XMATH_Wrap(int, int, int);

//001F3C98
float XMATH_WrapLimit(int, int, int);

//001F3CAA
int XMATH_MagSq(TPoint const *);

//001F3CC8
float XMATH_ClampMag(TPoint *, int);

//001F3CF2
float XMATH_ClampMagMin(TPoint *, int);

//001F3D12
int XMATH_DistanceSq(TPoint const *, TPoint const *);

//001F3D38
int XMATH_Distance3DSq(TPoint3D const *, TPoint3D const *);

//001F3D78
uint64_t XMATH_Distance(TPoint const *, TPoint const *);

//001F3D94
float XMATH_Distance3DF(TPointF3D *, TPointF3D *);

//001F3DD4
float XMATH_Interpolate(int, int, int, int, int);

//001F3DF0
float XMATH_InterpAngle(int, int, int, int, int);

//001F3E18
float XMATH_InterpolateFloat(float, float, float, float, float);

//001F3E4A
int XMATH_InterpolateClamp(int, int, int, int, int);

//001F3E92
int XMATH_SinInterpolateClamp(int, int, int, int, int);

//001F3EB8
float XMATH_SinInterpolateClampFloat(float, float, float, float, float);

//001F3F20
float XMATH_InterpolatePos(TPoint *, int, int, int, TPoint, TPoint);

//001F3F74
void XMATH_InterpolatePos3D(TPoint3D *, int, int, int, TPoint3D, TPoint3D);

//001F3FFC
void XMATH_SinInterpolatePos3D(TPoint3D *, int, int, int, TPoint3D, TPoint3D);

//001F4084
float XMATH_SetupRectI(TRectI *, int, int, int, int);

//001F408E
void XMATH_SetupRect(TRect *, float, float, float, float);

//001F409C
float XMATH_WrapToBounds(int, int, int);

//001F40AE
float XMATH_RectOverlap(TRect, float, float, float, float);

//001F4138
float XMATH_RectOverlap(TRect, TRect);

//001F41D4
float XMATH_Dot_F(TPointF3D *, TPointF3D *);

//001F41FE
float XMATH_DotProduct(TPoint *, TPoint *);

//001F4214
uint XMATH_RGBDiff(uint, uint);

//001F424C
float XMATH_MaxF(float, float);

//001F4268
float XMATH_MinF(float, float);

//001F4284
bool XMATH_IsCrossingLine(int, int, int);

//001F42AA
float XMATH_IsCrossingLine2D(TPoint, TPoint, TPoint, TPoint);

//001F432C
float XMATH_IsCrossingLineOneWay(int, int, int, int);

//001F4344
float XMATH_IsStayingOneSideOf(int, int, int, int);

//001F435C
float XMATH_IsStayingBetween(int, int, int, int);

//001F4376
float XMATH_IsPwrTwo(int);

//001F438A
TPointF XMATH_GetCurvePosF(TPointF pf1, TPointF pf2, TPointF pf3, float f4);

//001F43E0
float XMATH_CreateRandomIndexArray(int *, int);

//001F4416
float XMATH_ShuffleArray(ushort *, int);

//001F4440
float XMATH_CountNumDigits(int);

//001F445C
float XMATH_RoundToNearest(int, int);

//001F4476
float XMATH_RoundFloatToNearestInt(float);

//001F449E CFTTVector32 const&,CFTTVector32 const&,CFTTVector32 const&,CFTTVector32 const&,float
CFTTVector32 XMATH_CatmullRom(CFTTVector32 const &v1,
                              CFTTVector32 const &v2,
                              CFTTVector32 const &v3,
                              CFTTVector32 const &v4,
                              float f5);

//001F459E
float XMATH_StringToYardInt(char const *);

//001F4638
int XMATH_ClipPathBounds(TPoint3D *, TPoint3D *, int, int, int, int);

//001F4680
float XMATH_ClipPathBounds(TPoint *, TPoint *, int, int, int, int);

int xsin(int a1);
int xcos(int a1);

#endif  //_XMATH_H_