ixmilia / dxf

MIT License
205 stars 65 forks source link

Offset of a polyline. #178

Closed VinayFdes closed 1 year ago

VinayFdes commented 2 years ago

How to create a polyline offset to an already existing polyline? Please refer to the image. I want to create a line(the red one ) at an offset of say 5mm. How to maintain the 'curve' just like existing line ? image

nzain commented 2 years ago

You cannot offset any polyline. You can, of course, offset line segments and you can offset arc segments (need to understand bulge first).

However, some weird cases are degenerate:

And whenever the polyline segments change direction (discontinuous 1st derivative), such an algorithm would need to calculate intersection points for each offset segment. Not impossible, but not trivial either. Your sample looks smooth and an offset polyline would be reasonable. However, I think such logic is too specialized to be implemented in this library. This is not about DXF functionality, but goes a lot deeper into general geometry.

If you want to solve this on your own, try to construct arc segments from (point,point,bulge) first. When you have the center, it is easy to calculate a simple offset. Eventually you can skip the segment-segment intersection, if your polyline is smooth.

Best, Patrick

VinayFdes @.***> schrieb am Mi., 20. Apr. 2022, 15:16:

How to create a polyline offset to an already existing polyline? Please refer to the image. I want to create a line(the red one ) at an offset of say 5mm. How to maintain the 'curve' just line existing line ? [image: image] https://user-images.githubusercontent.com/98016592/164238471-82ebd61f-aa73-4334-954f-759d576a8380.png

— Reply to this email directly, view it on GitHub https://github.com/ixmilia/dxf/issues/178, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADKQV64DGIBQWLAPBXIF44DVF77URANCNFSM5T4ANQ6A . You are receiving this because you are subscribed to this thread.Message ID: @.***>