// // Licensed under the MIT License. See LICENSE file in the project root for full license information. // namespace MUnique.OpenMU.GameLogic; using MUnique.OpenMU.Pathfinding; /// /// Extensions for . /// public static class PointExtensions { /// /// Determines whether if the point is within bounds of the specified rectangle. /// The border points of the rectangle are inclusive. /// /// The point. /// The rectangle. /// true if the point is within bounds of the specified rectangle; otherwise, false. public static bool IsWithinBoundsOf(this Point point, Rectangle rectangle) { return point.X >= rectangle.X1 && point.X <= rectangle.X2 && point.Y >= rectangle.Y1 && point.Y <= rectangle.Y2; } /// /// Gets the angle degree from start point to a target point. /// /// The start point. /// The target point. /// The angle between 0 and 360 degree. /// This matches with the angle which gets received by area skill packets. public static double GetAngleDegreeTo(this Point start, Point target) { var diffX = start.X - target.X; var diffY = start.Y - target.Y; var radian = Math.Atan2(diffY, diffX); var result = (radian * 180 / Math.PI) - 90; if (result < 0) { result += 360; } return result; } }