mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-14 12:35:07 -05:00
Geometry, nesting and import code now call PortableMath instead of System.Math for Sin, Cos, Tan, Atan, Atan2, Asin and Acos (Core, Engine, IO, Data; 269 calls in 64 files). A test fails if those projects call the runtime's trig again. With the runtime's trig, Windows and Linux disagreed in the last bit at non-quarter angles and the same job could nest differently: the learned-angle nests (a cross fixture) placed 23 parts in Strip on Windows and 28 on Linux. Now every Engine.Tests pin gives the same layout on both (3600 passing on Linux and on DesktopPC), Linux layouts are unchanged, and the learned-angle rows are re-pinned to the shared layouts, which pass the overlap and work-area checks, and run on every platform again. Fixes Project Memory 518f3b58.
60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using OpenNest.Geometry;
|
|
using OpenNest.Math;
|
|
|
|
namespace OpenNest.CNC.CuttingStrategy
|
|
{
|
|
public class LineLineLeadIn : LeadIn
|
|
{
|
|
public double Length1 { get; set; }
|
|
public double ApproachAngle1 { get; set; } = 90.0;
|
|
public double Length2 { get; set; }
|
|
public double ApproachAngle2 { get; set; } = 90.0;
|
|
|
|
public override List<ICode> Generate(
|
|
Vector contourStartPoint,
|
|
double contourNormalAngle,
|
|
RotationType winding = RotationType.CW
|
|
)
|
|
{
|
|
var piercePoint = GetPiercePoint(contourStartPoint, contourNormalAngle);
|
|
|
|
var secondAngle = contourNormalAngle - Angle.HalfPI + Angle.ToRadians(ApproachAngle1);
|
|
var midPoint = new Vector(
|
|
contourStartPoint.X + Length2 * PortableMath.Cos(secondAngle),
|
|
contourStartPoint.Y + Length2 * PortableMath.Sin(secondAngle)
|
|
);
|
|
|
|
return new List<ICode>
|
|
{
|
|
new RapidMove(piercePoint),
|
|
new LinearMove(midPoint) { Layer = LayerType.Leadin },
|
|
new LinearMove(contourStartPoint) { Layer = LayerType.Leadin },
|
|
};
|
|
}
|
|
|
|
public override Vector GetPiercePoint(Vector contourStartPoint, double contourNormalAngle,
|
|
RotationType winding = RotationType.CW)
|
|
{
|
|
var secondAngle = contourNormalAngle - Angle.HalfPI + Angle.ToRadians(ApproachAngle1);
|
|
var midX = contourStartPoint.X + Length2 * PortableMath.Cos(secondAngle);
|
|
var midY = contourStartPoint.Y + Length2 * PortableMath.Sin(secondAngle);
|
|
|
|
var firstAngle = secondAngle + Angle.ToRadians(ApproachAngle2);
|
|
return new Vector(
|
|
midX + Length1 * PortableMath.Cos(firstAngle),
|
|
midY + Length1 * PortableMath.Sin(firstAngle)
|
|
);
|
|
}
|
|
|
|
public override LeadIn Scale(double factor) =>
|
|
new LineLineLeadIn
|
|
{
|
|
Length1 = Length1 * factor,
|
|
ApproachAngle1 = ApproachAngle1,
|
|
Length2 = Length2 * factor,
|
|
ApproachAngle2 = ApproachAngle2,
|
|
};
|
|
}
|
|
}
|