pyclipper icon indicating copy to clipboard operation
pyclipper copied to clipboard

Offset needs to be scaled?

Open diegogangl opened this issue 7 years ago • 2 comments
trafficstars

It seems that when trying to execute an offset, you need to scale the value according to the scale of the coordinates (the original, before calling scale_to_clipper())

I have a set of coordinates that look like this:

(0.02196335606276989, 0.025453664362430573), 
(0.021962668746709824, 0.02545437589287758), 
(0.021961797028779984, 0.025455275550484657)

Passing -7.0 to PyclipperOffset as the docs suggest doesn't affect the path at all. I have to use a rather large number instead:

solution = pco.Execute(1500.0 ** 2)

Not sure whether this is a bug or a detail that may have escaped me, but I couldn't find anything about scaling the offset on the docs. It seems the offset depends on the path size too? For larger paths (300 meters in scale) I had to use 5000 ** 3 before seeing any change.

diegogangl avatar Feb 09 '18 13:02 diegogangl

I found out that the offset's value has to be multiplied by the scale's default parameter (2**31). And since I was trying to get sizes in mm with a coordinate system in meters, I also have to multiply it by 0.001 first. Feel free to close this if it's not a bug.

diegogangl avatar Feb 15 '18 18:02 diegogangl

I see this same issue. If I do not use scale_to_clipper and scale_from_clipper, then the offset amount is applied as it should be to the polygon. If I scale the polygon, I have to scale the offset.

ktrussell avatar May 17 '18 03:05 ktrussell