38 lines
928 B
C++
38 lines
928 B
C++
#ifndef A8_VEC2_H
|
|
#define A8_VEC2_H
|
|
|
|
namespace a8
|
|
{
|
|
struct Vec2
|
|
{
|
|
float x = 0.0f;
|
|
float y = 0.0f;
|
|
|
|
Vec2(float _x = 0.0f, float _y = 0.0f):x(_x), y(_y) {};
|
|
|
|
void Normalize();
|
|
void Rotate(float angle);
|
|
float CalcAngle(const Vec2& b);
|
|
float CalcAngleEx(const Vec2& b);
|
|
static Vec2 FromAngle(float angle);
|
|
float Distance(const Vec2& b);
|
|
float ManhattanDistance(const Vec2& b);
|
|
|
|
bool operator == (const Vec2& b) const;
|
|
Vec2 operator + (const Vec2& b) const;
|
|
Vec2 operator - (const Vec2& b) const;
|
|
Vec2 operator * (float scale) const;
|
|
Vec2 operator / (float scale) const;
|
|
Vec2 Perp();
|
|
float Dot(const Vec2& v) const;
|
|
float Norm() const;
|
|
|
|
static const Vec2 UP;
|
|
static const Vec2 DOWN;
|
|
static const Vec2 LEFT;
|
|
static const Vec2 RIGHT;
|
|
};
|
|
}
|
|
|
|
#endif
|