using System; namespace RGB.NET.Core; /// /// Offers some extensions and helper-methods for related things. /// public static class PointExtensions { #region Methods /// /// Moves the specified by the specified amount. /// /// The to move. /// The x-ammount to move. /// The y-ammount to move. /// The new location of the point. public static Point Translate(this Point point, float x = 0, float y = 0) => new(point.X + x, point.Y + y); /// /// Rotates the specified by the specified amuont around the specified origin. /// /// The to rotate. /// The rotation. /// The origin to rotate around. [0,0] if not set. /// The new location of the point. public static Point Rotate(this Point point, Rotation rotation, Point origin = new()) { float sin = MathF.Sin(rotation.Radians); float cos = MathF.Cos(rotation.Radians); float x = point.X - origin.X; float y = point.Y - origin.Y; x = (x * cos) - (y * sin); y = (x * sin) + (y * cos); return new Point(x + origin.X, y + origin.Y); } #endregion }