nanoLogika / ACadSvg

C# library to convert AutoCAD drawings from DWG to SVG. AutoCAD files are read using ACadSharp.
GNU Lesser General Public License v3.0
9 stars 2 forks source link

LWPOLYLINE: Bulge --> AddArc #21

Closed mme1950 closed 9 months ago

mme1950 commented 9 months ago

LWPOLYLINE vertices can have a bulge property. bulge defines circular arc between the this vertex and the next vertex.

mme1950 commented 9 months ago

If the bulge property af a vertex is nonzero the line to the next vertex shall be a circular arc. This has to be converted to a arc clause in the d attribute of a SVG path element.

XY a
XY e

XY chord= e-a

d = chord.GetLength() / 2
sagitta = d * |bulge|

     d^2 + sagitta^2
r = ----------------
          2 sagitta

r < sagitta --> lf = 1
bulge > 0 --> sf = 1

SVG path:   d="M {a.X} {a.Y} A {r} {r} 0 {lf} {sf} e.X e.Y"