From 2f7691e26aa305be995f8548a800bc59fb40a7f2 Mon Sep 17 00:00:00 2001 From: Mikolaj505 <61552376+Mikolaj505@users.noreply.github.com> Date: Mon, 23 Mar 2026 15:45:09 +0100 Subject: [PATCH] fix: Handling mirrored case when applying transform --- src/ACadSharp/Entities/LwPolyLine.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/ACadSharp/Entities/LwPolyLine.cs b/src/ACadSharp/Entities/LwPolyLine.cs index 47bfcc6eb..807cfd162 100644 --- a/src/ACadSharp/Entities/LwPolyLine.cs +++ b/src/ACadSharp/Entities/LwPolyLine.cs @@ -123,12 +123,27 @@ public override void ApplyTransform(Transform transform) this.getWorldMatrix(transform, this.Normal, newNormal, out Matrix3 transOW, out Matrix3 transWO); + var m = transform.Matrix; + double det = + m.M00 * m.M11 - + m.M01 * m.M10; + + bool mirrored = det < 0; + foreach (var vertex in this.Vertices) { - XYZ v = transOW * vertex.Location.Convert(); - v = transform.ApplyTransform(v); - v = transWO * v; - vertex.Location = v.Convert(); + // OCS → WCS + XYZ transformationVector = transOW * vertex.Location.Convert(); + transformationVector = transform.ApplyTransform(transformationVector); + + // WCS → new OCS + transformationVector = transWO * transformationVector; + vertex.Location = transformationVector.Convert(); + + if (mirrored && vertex.Bulge != 0.0) + { + vertex.Bulge = -vertex.Bulge; + } } this.Normal = newNormal;