public static Vector2 GetDirectionalVector(Vector2 v) { if (v.X == 0) { if (v.Y > 0) return new Vector2(0, 1); else if (v.Y < 0) return new Vector2(0, -1); } else if (v.X > 0) { if (v.Y == 0) return new Vector2(1, 0); else if (v.Y == v.X) return new Vector2(1, 1); } else { if (v.Y == 0) return new Vector2(-1, 0); else if (v.Y == v.X) return new Vector2(-1, -1); } return new Vector2(0, 0); }
public Point2 Add(Vector2 dv) { return new Point2(X + dv.X, Y + dv.Y); }
public Point2 Rotate90(Vector2 pivot) { return Add(-pivot) .Rotate90() .Add(pivot); }