The offset direction (start→pierce) is reversed from the approach direction (pierce→start), so the old formula produced 180°−angle instead of the requested angle. Invisible at the 90° default but caused 45° to render as 135°. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using OpenNest.Geometry;
|
|
using OpenNest.Math;
|
|
using System.Collections.Generic;
|
|
|
|
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)
|
|
{
|
|
var approachAngle = contourNormalAngle - Angle.HalfPI + Angle.ToRadians(ApproachAngle);
|
|
return new Vector(
|
|
contourStartPoint.X + Length * System.Math.Cos(approachAngle),
|
|
contourStartPoint.Y + Length * System.Math.Sin(approachAngle));
|
|
}
|
|
|
|
public override LeadIn Scale(double factor) =>
|
|
new LineLeadIn { Length = Length * factor, ApproachAngle = ApproachAngle };
|
|
}
|
|
}
|