Files
UVtools/UVtools.Core/Extensions/PointExtensions.cs
T
Tiago Conceição 86851114d1 v2.3.1
* (Add) Calibrator - Stress Tower: Generates a stress tower to test the printer capabilities
* (Add) PrusaSlicer printer: UVtools Prusa SL1, for SL1 owners must use this profile to be UVtools compatible when using advanced tools
* (Fix) Tool - Calculator - Optimal model tilt: Layer height wasn't get pulled from loaded file and fixed to 0.05mm
* **(Fix) FileFormats:**
  * When change a global print paramenter, it will only set this same parameter on every layer, keeping other parameters intact, it was reseting every parameter per layer to globals
  * SL1: Verify if files are malformed and if there's missing configuration files (#126)
  * CTBv3: Set EncryptionMode to 0x2000000F, this allow the use of per layer settings
2021-01-19 21:51:52 +00:00

27 lines
901 B
C#

using System;
using System.Drawing;
namespace UVtools.Core.Extensions
{
public static class PointExtensions
{
public static double FindLength(Point start, Point end) => Math.Sqrt(Math.Pow(end.Y - start.Y, 2) + Math.Pow(end.X - start.X, 2));
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.Y;
Point rotated = new Point((int)Math.Round(x), (int)Math.Round(y));
return rotated;
}
}
}