feat: add Bend domain model and BendDirection enum to OpenNest.Core
Introduces OpenNest.Core/Bending/ with Bend and BendDirection types as the foundation for bend line detection. Includes 6 passing unit tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
37
OpenNest.Core/Bending/Bend.cs
Normal file
37
OpenNest.Core/Bending/Bend.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using OpenNest.Geometry;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.Bending
|
||||
{
|
||||
public class Bend
|
||||
{
|
||||
public Vector StartPoint { get; set; }
|
||||
public Vector EndPoint { get; set; }
|
||||
public BendDirection Direction { get; set; }
|
||||
public double? Angle { get; set; }
|
||||
public double? Radius { get; set; }
|
||||
public string NoteText { get; set; }
|
||||
|
||||
public double Length => StartPoint.DistanceTo(EndPoint);
|
||||
|
||||
public double AngleRadians => Angle.HasValue
|
||||
? OpenNest.Math.Angle.ToRadians(Angle.Value)
|
||||
: 0;
|
||||
|
||||
public Line ToLine() => new Line(StartPoint, EndPoint);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the angle of the bend line itself (not the bend angle).
|
||||
/// Used for grain direction comparison.
|
||||
/// </summary>
|
||||
public double LineAngle => StartPoint.AngleTo(EndPoint);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var dir = Direction.ToString();
|
||||
var angle = Angle?.ToString("0.##") ?? "?";
|
||||
var radius = Radius?.ToString("0.###") ?? "?";
|
||||
return $"{dir} {angle}° R{radius}";
|
||||
}
|
||||
}
|
||||
}
|
||||
9
OpenNest.Core/Bending/BendDirection.cs
Normal file
9
OpenNest.Core/Bending/BendDirection.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace OpenNest.Bending
|
||||
{
|
||||
public enum BendDirection
|
||||
{
|
||||
Unknown,
|
||||
Up,
|
||||
Down
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user