using System;
namespace RGB.NET.Core
{
public static class PointExtensions
{
#region Methods
///
/// Moves the specified by the given 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, double x = 0, double y = 0) => new(point.X + x, point.Y + y);
///
/// Rotates the specified by the given amuont around the given 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())
{
double sin = Math.Sin(rotation.Radians);
double cos = Math.Cos(rotation.Radians);
point = new Point(point.X - origin.X, point.Y - origin.Y);
point = new Point((point.X * cos) - (point.Y * sin), (point.X * sin) + (point.Y * cos));
return new Point(point.X + origin.X, point.Y + origin.Y); ;
}
#endregion
}
}