|
|
|
@ -159,26 +159,26 @@ namespace ImageProcessorCore |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Rotates a point around a given a rotation matrix.
|
|
|
|
/// Creates a rotation matrix for the given point and angle.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="point">The point to rotate</param>
|
|
|
|
/// <param name="rotation">Rotation matrix used</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static Point Rotate( Point point, Matrix3x2 rotation ) |
|
|
|
/// <param name="origin">The origin point to rotate around</param>
|
|
|
|
/// <param name="degrees">Rotation in degrees</param>
|
|
|
|
/// <returns>The rotation <see cref="Matrix3x2"/></returns>
|
|
|
|
public static Matrix3x2 CreateRotation(Point origin, float degrees) |
|
|
|
{ |
|
|
|
return new Point( Vector2.Transform( point.backingVector, rotation ) ); |
|
|
|
float radians = (float)ImageMaths.DegreesToRadians(degrees); |
|
|
|
return Matrix3x2.CreateRotation(radians, origin.backingVector); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a rotation matrix for
|
|
|
|
/// Rotates a point around a given a rotation matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="origion">The origin point to rotate around</param>
|
|
|
|
/// <param name="degrees">Rotation in degrees</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static Matrix3x2 CreateRotatation( Point origin, float degrees ) |
|
|
|
/// <param name="point">The point to rotate</param>
|
|
|
|
/// <param name="rotation">Rotation matrix used</param>
|
|
|
|
/// <returns>The rotated <see cref="Point"/></returns>
|
|
|
|
public static Point Rotate(Point point, Matrix3x2 rotation) |
|
|
|
{ |
|
|
|
float radians = (float)ImageMaths.DegreesToRadians( degrees ); |
|
|
|
return Matrix3x2.CreateRotation( radians, origin.backingVector ); |
|
|
|
return new Point(Vector2.Transform(point.backingVector, rotation)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -187,26 +187,48 @@ namespace ImageProcessorCore |
|
|
|
/// <param name="point">The point to rotate</param>
|
|
|
|
/// <param name="origin">The center point to rotate around.</param>
|
|
|
|
/// <param name="degrees">The angle in degrees.</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns>The rotated <see cref="Point"/></returns>
|
|
|
|
public static Point Rotate(Point point, Point origin, float degrees) |
|
|
|
{ |
|
|
|
float radians = (float)ImageMaths.DegreesToRadians(degrees); |
|
|
|
return new Point(Vector2.Transform(point.backingVector, Matrix3x2.CreateRotation(radians, origin.backingVector))); |
|
|
|
return new Point(Vector2.Transform(point.backingVector, CreateRotation(origin, degrees))); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Skews a point around a given origin by the specified angles in degrees.
|
|
|
|
/// Creates a skew matrix for the given point and angle.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="origin">The origin point to rotate around</param>
|
|
|
|
/// <param name="degreesX">The x-angle in degrees.</param>
|
|
|
|
/// <param name="degreesY">The y-angle in degrees.</param>
|
|
|
|
/// <returns>The rotation <see cref="Matrix3x2"/></returns>
|
|
|
|
public static Matrix3x2 CreateSkew(Point origin, float degreesX, float degreesY) |
|
|
|
{ |
|
|
|
float radiansX = (float)ImageMaths.DegreesToRadians(degreesX); |
|
|
|
float radiansY = (float)ImageMaths.DegreesToRadians(degreesY); |
|
|
|
return Matrix3x2.CreateSkew(radiansX, radiansY, origin.backingVector); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Skews a point using a given a skew matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="point">The point to rotate</param>
|
|
|
|
/// <param name="skew">Rotation matrix used</param>
|
|
|
|
/// <returns>The rotated <see cref="Point"/></returns>
|
|
|
|
public static Point Skew(Point point, Matrix3x2 skew) |
|
|
|
{ |
|
|
|
return new Point(Vector2.Transform(point.backingVector, skew)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Skews a point around a given origin by the specified angles in degrees.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="point">The point to skew.</param>
|
|
|
|
/// <param name="origin">The center point to rotate around.</param>
|
|
|
|
/// <param name="degreesX">The x-angle in degrees.</param>
|
|
|
|
/// <param name="degreesY">The y-angle in degrees.</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns>The skewed <see cref="Point"/></returns>
|
|
|
|
public static Point Skew(Point point, Point origin, float degreesX, float degreesY) |
|
|
|
{ |
|
|
|
float radiansX = (float)ImageMaths.DegreesToRadians(degreesX); |
|
|
|
float radiansY = (float)ImageMaths.DegreesToRadians(degreesY); |
|
|
|
return new Point(Vector2.Transform(point.backingVector, Matrix3x2.CreateSkew(degreesX, degreesY, origin.backingVector))); |
|
|
|
return new Point(Vector2.Transform(point.backingVector, CreateSkew(origin, degreesX, degreesY))); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
@ -223,8 +245,7 @@ namespace ImageProcessorCore |
|
|
|
return "Point [ Empty ]"; |
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
$"Point [ X={this.X}, Y={this.Y} ]"; |
|
|
|
return $"Point [ X={this.X}, Y={this.Y} ]"; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|