添加马哈顿距离判断
This commit is contained in:
parent
8303f98fe3
commit
51e1820242
@ -98,6 +98,12 @@ namespace a8
|
|||||||
return v.Norm();
|
return v.Norm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Vec2::ManhattanDistance(const Vec2& b)
|
||||||
|
{
|
||||||
|
float distance = std::fabs(x - b.x) + std::fabs(y - b.y);
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
Vec2 Vec2::Perp()
|
Vec2 Vec2::Perp()
|
||||||
{
|
{
|
||||||
return Vec2(y, -x);
|
return Vec2(y, -x);
|
||||||
|
@ -16,6 +16,7 @@ namespace a8
|
|||||||
float CalcAngleEx(const Vec2& b);
|
float CalcAngleEx(const Vec2& b);
|
||||||
static Vec2 FromAngle(float angle);
|
static Vec2 FromAngle(float angle);
|
||||||
float Distance(const Vec2& b);
|
float Distance(const Vec2& b);
|
||||||
|
float ManhattanDistance(const Vec2& b);
|
||||||
|
|
||||||
bool operator == (const Vec2& b) const;
|
bool operator == (const Vec2& b) const;
|
||||||
Vec2 operator + (const Vec2& b) const;
|
Vec2 operator + (const Vec2& b) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user