From 38fdc1e47088893cb90cbda2e9da417725100356 Mon Sep 17 00:00:00 2001 From: Iain Hermansson Date: Mon, 12 Oct 2026 16:48:58 +0100 Subject: [PATCH] Fixes the extend arc method when start angle is not 0 Changed the way the method does the extension. Instead of rotating the coordinate system the arc is based on it uses the start angle as negative. --- Geometry_Engine/Modify/Extend.cs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Geometry_Engine/Modify/Extend.cs b/Geometry_Engine/Modify/Extend.cs index 08274f0c8..46216cb10 100644 --- a/Geometry_Engine/Modify/Extend.cs +++ b/Geometry_Engine/Modify/Extend.cs @@ -68,37 +68,28 @@ public static ICurve Extend(this Arc curve, double start = 0.0, double end = 0.0 { if (tangentExtensions) return curve.ExtendTangent(start, end, tolerance); - - if (curve.StartAngle != 0) - { - curve.CoordinateSystem = curve.CoordinateSystem.Rotate(curve.CoordinateSystem.Origin, curve.CoordinateSystem.Z, curve.StartAngle); - curve.EndAngle = -curve.StartAngle; - curve.StartAngle = 0; - } - + double startAngleExt = start / curve.Radius; double endAngleExt = end / curve.Radius; - - if (startAngleExt + endAngleExt + curve.EndAngle < tolerance) + + if (endAngleExt + startAngleExt - curve.StartAngle + curve.EndAngle < tolerance) { Base.Compute.RecordError("Negative extend values are smaller than curve length."); return null; } - if (startAngleExt + endAngleExt + curve.EndAngle - (2 * Math.PI) > tolerance) + if (Math.Abs(startAngleExt + endAngleExt + curve.EndAngle - curve.StartAngle) - (2 * Math.PI) > tolerance) { Base.Compute.RecordError("Extension values too great."); return null; } - Cartesian oldCS = curve.CoordinateSystem; - Cartesian newCS = oldCS.Rotate(oldCS.Origin, oldCS.Z, -startAngleExt); return new Arc { - CoordinateSystem = newCS, + CoordinateSystem = curve.CoordinateSystem, Radius = curve.Radius, - StartAngle = 0, - EndAngle = curve.EndAngle + startAngleExt + endAngleExt + StartAngle = curve.StartAngle - startAngleExt, + EndAngle = curve.EndAngle + endAngleExt, }; }