Files
OpenNest/OpenNest.Engine/Jobs/RotationPolicy.cs
T
aj 451841401a refactor(engine): align namespaces with directory layout under OpenNest.Engine
All 132 OpenNest.Engine source files now declare namespaces matching
their nested directories: Jobs/, Jobs/Placement/, Jobs/Adapters/,
Fill/, RectanglePacking/, CirclePacking/, and engine-root types moved
from 'OpenNest' to 'OpenNest.Engine'. RootNamespace updated accordingly.
Consumers (Api, Console, Mcp, Benchmark, Training, desktop app, tests)
gained the explicit usings the move requires; CLAUDE.md updated.
2026-09-21 13:18:34 -04:00

48 lines
1.6 KiB
C#

using System;
namespace OpenNest.Engine.Jobs;
public enum RotationPolicyKind
{
Fixed,
BoundedSweep,
Automatic,
}
/// <summary>Immutable rotation constraints, in radians about the geometry origin.</summary>
public sealed class RotationPolicy
{
private RotationPolicy(RotationPolicyKind kind, double start, double end, double step)
{
if (!double.IsFinite(start) || !double.IsFinite(end) || !double.IsFinite(step))
throw new ArgumentException("Angles must be finite.");
Kind = kind;
Start = start;
End = end;
Step = step;
}
public RotationPolicyKind Kind { get; }
public double Start { get; }
public double End { get; }
public double Step { get; }
public static RotationPolicy Automatic { get; } = new(RotationPolicyKind.Automatic, 0, 0, 0);
public static RotationPolicy Fixed(double angle) =>
new(RotationPolicyKind.Fixed, angle, angle, 0);
public static RotationPolicy BoundedSweep(double start, double end, double step)
{
if (step <= 0 || end < start)
throw new ArgumentException("Sweep needs a positive step and ordered bounds.");
return new RotationPolicy(RotationPolicyKind.BoundedSweep, start, end, step);
}
/// <summary>Preserves the legacy zero-step automatic sentinel; zero never means locked rotation.</summary>
public static RotationPolicy FromLegacy(
double stepAngle,
double rotationStart,
double rotationEnd
) => stepAngle == 0 ? Automatic : BoundedSweep(rotationStart, rotationEnd, stepAngle);
}