Menu

Variable line offset

2015-08-20
2015-09-03
  • Bert van 't Veer

    Thanks for this great library. I'm trying to employ the offset function on open polylines to create connected wall segments, however each segment can have varying thickness. Do you have any suggestions for modifying the source to accomodate for this? I've messed around with the GetUnitNormal() and OffsetPoint() functions, but so far couldn't produce any consistent results. Thanks in advance for any pointers in the right direction.

    Bert van 't Veer

     
  • Timo Kähkönen

    Timo Kähkönen - 2015-08-20

    Varying delta by segment should be possible at least when miter joins are used, but to make it work with eg. round joins, it gets complicated as the attached image shows. When delta varies, it is hard to decide where to draw the arc as there are two different sized circles per source polygon vertex.

     
    • Bert van 't Veer

      Thanks Timo, I do intent to use miter joints but I'm having some troubles on the implementation. I'm not sure whether to modify the unit normals or do some magic in the OffsetPoint function. Any hints?

       
  • Timo Kähkönen

    Timo Kähkönen - 2015-09-03

    I tried in experimental Javascript FPoint Clipper:
    http://codepen.io/timo22345/pen/LpEbWB/left/?editors=101

    • window.widths is array of offsets of edges (at the end of HTML-window)
    • these offsets are set as Z-members of points (in make_offset() in HTML-window)
    • GetUnitNormal uses these these offsets as a dividend in var f = 1 / Math.sqrt(dx * dx + dy * dy) in place of 1 (in Javascript-window)

    • However this is'nt enough as you see, if you rotate the polygons, use negative offset etc.

    --> It seems that major refactoring is needed to support per edge based offsets.