Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'UVtools.Core/Extensions/PointExtensions.cs')
-rw-r--r--UVtools.Core/Extensions/PointExtensions.cs3
1 files changed, 2 insertions, 1 deletions
diff --git a/UVtools.Core/Extensions/PointExtensions.cs b/UVtools.Core/Extensions/PointExtensions.cs
index 077b869..9a0ee94 100644
--- a/UVtools.Core/Extensions/PointExtensions.cs
+++ b/UVtools.Core/Extensions/PointExtensions.cs
@@ -9,13 +9,14 @@ namespace UVtools.Core.Extensions
public static Point Rotate(this Point point, double angleDegree, Point pivot = default)
{
+ if (angleDegree == 0 || angleDegree == 360) return point;
double angle = angleDegree * Math.PI / 180;
double cos = Math.Cos(angle);
double sin = Math.Sin(angle);
int dx = point.X - pivot.X;
int dy = point.Y - pivot.Y;
double x = cos * dx - sin * dy + pivot.X;
- double y = sin * dx + cos * dy + pivot.X;
+ double y = sin * dx + cos * dy + pivot.Y;
Point rotated = new Point((int)Math.Round(x), (int)Math.Round(y));
return rotated;