2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _CVECTOR2F
|
|
|
|
#define _CVECTOR2F
|
2022-04-16 07:50:32 +00:00
|
|
|
|
2022-07-02 05:30:04 +00:00
|
|
|
#include "types.h"
|
2022-04-16 07:50:32 +00:00
|
|
|
|
|
|
|
class CVector2f {
|
2022-10-04 21:00:16 +00:00
|
|
|
static const CVector2f skZeroVector;
|
2022-10-09 05:13:17 +00:00
|
|
|
|
2022-04-16 07:50:32 +00:00
|
|
|
public:
|
2022-10-04 21:00:16 +00:00
|
|
|
CVector2f(f32 x, f32 y);
|
2022-07-02 05:30:04 +00:00
|
|
|
f32 GetX() const { return mX; }
|
|
|
|
f32 GetY() const { return mY; }
|
|
|
|
|
2022-10-04 21:00:16 +00:00
|
|
|
CVector2f& operator+=(const CVector2f& rhs);
|
|
|
|
CVector2f& operator-=(const CVector2f& rhs);
|
|
|
|
CVector2f& operator*=(float rhs);
|
|
|
|
CVector2f& operator/=(float rhs);
|
|
|
|
|
|
|
|
CVector2f& Normalize();
|
|
|
|
|
2022-10-01 20:39:52 +00:00
|
|
|
f32 Magnitude() const;
|
2022-10-04 21:00:16 +00:00
|
|
|
f32 MagSquared() const;
|
|
|
|
CVector2f AsNormalized() const;
|
2022-10-01 20:39:52 +00:00
|
|
|
|
2022-10-04 21:00:16 +00:00
|
|
|
static float GetAngleDiff(const CVector2f& a, const CVector2f& b);
|
|
|
|
static float Dot(const CVector2f& a, const CVector2f& b);
|
2022-10-09 05:13:17 +00:00
|
|
|
|
2022-10-04 21:00:16 +00:00
|
|
|
private:
|
2022-07-02 05:30:04 +00:00
|
|
|
f32 mX;
|
|
|
|
f32 mY;
|
2022-04-16 07:50:32 +00:00
|
|
|
};
|
|
|
|
|
2022-10-04 21:00:16 +00:00
|
|
|
CVector2f operator+(const CVector2f& lhs, const CVector2f& rhs);
|
|
|
|
CVector2f operator-(const CVector2f& lhs, const CVector2f& rhs);
|
|
|
|
bool operator==(const CVector2f& lhs, const CVector2f& rhs);
|
|
|
|
CVector2f operator*(const CVector2f& lhs, const float& rhs);
|
|
|
|
CVector2f operator*(const float& lhs, const CVector2f& rhs);
|
|
|
|
CVector2f operator/(const CVector2f& lhs, const float& rhs);
|
2022-10-01 20:39:52 +00:00
|
|
|
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _CVECTOR2F
|