Move math utilities to OpenNest.Math namespace
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.Geometry
|
||||
{
|
||||
@@ -139,8 +140,8 @@ namespace OpenNest.Geometry
|
||||
public Vector StartPoint()
|
||||
{
|
||||
return new Vector(
|
||||
Center.X + Radius * Math.Cos(StartAngle),
|
||||
Center.Y + Radius * Math.Sin(StartAngle));
|
||||
Center.X + Radius * System.Math.Cos(StartAngle),
|
||||
Center.Y + Radius * System.Math.Sin(StartAngle));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -150,8 +151,8 @@ namespace OpenNest.Geometry
|
||||
public Vector EndPoint()
|
||||
{
|
||||
return new Vector(
|
||||
Center.X + Radius * Math.Cos(EndAngle),
|
||||
Center.Y + Radius * Math.Sin(EndAngle));
|
||||
Center.X + Radius * System.Math.Cos(EndAngle),
|
||||
Center.Y + Radius * System.Math.Sin(EndAngle));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -201,8 +202,8 @@ namespace OpenNest.Geometry
|
||||
var angle = stepAngle * i + StartAngle;
|
||||
|
||||
points.Add(new Vector(
|
||||
Math.Cos(angle) * Radius + Center.X,
|
||||
Math.Sin(angle) * Radius + Center.Y));
|
||||
System.Math.Cos(angle) * Radius + Center.X,
|
||||
System.Math.Sin(angle) * Radius + Center.Y));
|
||||
}
|
||||
|
||||
return points;
|
||||
@@ -213,7 +214,7 @@ namespace OpenNest.Geometry
|
||||
/// </summary>
|
||||
public override double Length
|
||||
{
|
||||
get { return Diameter * Math.PI * SweepAngle() / Angle.TwoPI; }
|
||||
get { return Diameter * System.Math.PI * SweepAngle() / Angle.TwoPI; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -356,10 +357,10 @@ namespace OpenNest.Geometry
|
||||
if (Angle.IsBetweenRad(Angle.HalfPI, angle1, angle2))
|
||||
maxY = Center.Y + Radius;
|
||||
|
||||
if (Angle.IsBetweenRad(Math.PI, angle1, angle2))
|
||||
if (Angle.IsBetweenRad(System.Math.PI, angle1, angle2))
|
||||
minX = Center.X - Radius;
|
||||
|
||||
const double oneHalfPI = Math.PI * 1.5;
|
||||
const double oneHalfPI = System.Math.PI * 1.5;
|
||||
|
||||
if (Angle.IsBetweenRad(oneHalfPI, angle1, angle2))
|
||||
minY = Center.Y - Radius;
|
||||
@@ -405,8 +406,8 @@ namespace OpenNest.Geometry
|
||||
if (Angle.IsBetweenRad(angle, StartAngle, EndAngle, IsReversed))
|
||||
{
|
||||
return new Vector(
|
||||
Math.Cos(angle) * Radius + Center.X,
|
||||
Math.Sin(angle) * Radius + Center.Y);
|
||||
System.Math.Cos(angle) * Radius + Center.X,
|
||||
System.Math.Sin(angle) * Radius + Center.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.Geometry
|
||||
{
|
||||
@@ -84,7 +85,7 @@ namespace OpenNest.Geometry
|
||||
/// <returns></returns>
|
||||
public double Area()
|
||||
{
|
||||
return Math.PI * Radius * Radius;
|
||||
return System.Math.PI * Radius * Radius;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -93,7 +94,7 @@ namespace OpenNest.Geometry
|
||||
/// <returns></returns>
|
||||
public double Circumference()
|
||||
{
|
||||
return Math.PI * Diameter;
|
||||
return System.Math.PI * Diameter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -131,8 +132,8 @@ namespace OpenNest.Geometry
|
||||
var angle = stepAngle * i;
|
||||
|
||||
points.Add(new Vector(
|
||||
Math.Cos(angle) * Radius + Center.X,
|
||||
Math.Sin(angle) * Radius + Center.Y));
|
||||
System.Math.Cos(angle) * Radius + Center.X,
|
||||
System.Math.Sin(angle) * Radius + Center.Y));
|
||||
}
|
||||
|
||||
return points;
|
||||
@@ -290,8 +291,8 @@ namespace OpenNest.Geometry
|
||||
var angle = Center.AngleTo(pt);
|
||||
|
||||
return new Vector(
|
||||
Math.Cos(angle) * Radius + Center.X,
|
||||
Math.Sin(angle) * Radius + Center.Y);
|
||||
System.Math.Cos(angle) * Radius + Center.X,
|
||||
System.Math.Sin(angle) * Radius + Center.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -324,7 +325,7 @@ namespace OpenNest.Geometry
|
||||
public override bool Intersects(Circle circle)
|
||||
{
|
||||
var dist = Center.DistanceTo(circle.Center);
|
||||
return (dist < (Radius + circle.Radius) && dist > Math.Abs(Radius - circle.Radius));
|
||||
return (dist < (Radius + circle.Radius) && dist > System.Math.Abs(Radius - circle.Radius));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.Geometry
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.Geometry
|
||||
{
|
||||
@@ -219,7 +220,7 @@ namespace OpenNest.Geometry
|
||||
{
|
||||
var m1 = Slope();
|
||||
var m2 = line.Slope();
|
||||
return Math.Atan(Math.Abs((m2 - m1) / (1 + m2 * m1)));
|
||||
return System.Math.Atan(System.Math.Abs((m2 - m1) / (1 + m2 * m1)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -252,7 +253,7 @@ namespace OpenNest.Geometry
|
||||
{
|
||||
var x = EndPoint.X - StartPoint.X;
|
||||
var y = EndPoint.Y - StartPoint.Y;
|
||||
return Math.Sqrt(x * x + y * y);
|
||||
return System.Math.Sqrt(x * x + y * y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,10 +392,10 @@ namespace OpenNest.Geometry
|
||||
|
||||
public override Entity OffsetEntity(double distance, OffsetSide side)
|
||||
{
|
||||
var angle = OpenNest.Angle.NormalizeRad(Angle() + OpenNest.Angle.HalfPI);
|
||||
var angle = OpenNest.Math.Angle.NormalizeRad(Angle() + OpenNest.Math.Angle.HalfPI);
|
||||
|
||||
var x = Math.Cos(angle) * distance;
|
||||
var y = Math.Sin(angle) * distance;
|
||||
var x = System.Math.Cos(angle) * distance;
|
||||
var y = System.Math.Sin(angle) * distance;
|
||||
|
||||
var pt = new Vector(x, y);
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace OpenNest.Geometry
|
||||
if (Vertices.Count < 3)
|
||||
return 0.0;
|
||||
|
||||
return Math.Abs(CalculateArea());
|
||||
return System.Math.Abs(CalculateArea());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user