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.
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using OpenNest.Geometry;
|
|
using OpenNest.Math;
|
|
|
|
namespace OpenNest.CNC.CuttingStrategy
|
|
{
|
|
public class LineLeadIn : LeadIn
|
|
{
|
|
public double Length { get; set; }
|
|
public double ApproachAngle { get; set; } = 90.0;
|
|
|
|
public override List<ICode> Generate(
|
|
Vector contourStartPoint,
|
|
double contourNormalAngle,
|
|
RotationType winding = RotationType.CW
|
|
)
|
|
{
|
|
var piercePoint = GetPiercePoint(contourStartPoint, contourNormalAngle);
|
|
|
|
return new List<ICode>
|
|
{
|
|
new RapidMove(piercePoint),
|
|
new LinearMove(contourStartPoint) { Layer = LayerType.Leadin },
|
|
};
|
|
}
|
|
|
|
public override Vector GetPiercePoint(Vector contourStartPoint, double contourNormalAngle,
|
|
RotationType winding = RotationType.CW)
|
|
{
|
|
var approachAngle = contourNormalAngle - Angle.HalfPI + Angle.ToRadians(ApproachAngle);
|
|
return new Vector(
|
|
contourStartPoint.X + Length * PortableMath.Cos(approachAngle),
|
|
contourStartPoint.Y + Length * PortableMath.Sin(approachAngle)
|
|
);
|
|
}
|
|
|
|
public override LeadIn Scale(double factor) =>
|
|
new LineLeadIn { Length = Length * factor, ApproachAngle = ApproachAngle };
|
|
}
|
|
}
|