# Offset Shapes acts a bit funny for small features with metric system

See example below, when asking for outwards offset at respectively 0.125, 0.126 and 0.127mm

Basically only “some” values work as intended.
I suspect 0.127 mm works better because it’s exactly equal to 0.005 inches

I can confirm I get the same behavior. Seems to only happen with “Round” corner style and when specifying to 3 digits. I only tested in mm so not sure if that’s a factor.

The offending SVG.

Fascinating. I’m curious now what you’re making…

@LightBurn are you able to comment on this possible bug? It’s a corner case at the minimum.

The offset engine is done using Clipper (a freely available library) and it works in integers only, so everything is scaled up, fed through it, then scaled back down.

I noticed something recently when using really small text (the auto-weld feature on text uses the offset engine), so the next release bumps the scale up by a factor of four already (it was 256.0, now it’s 1024.0).

It seems we’ve already fixed it:

Very few users with CO2 lasers work at scales this small, but we’ve been working on improving the core engine for better handling of small scales for some upcoming changes.

2 Likes

Thanks for the insight. This had never come up for me since I’ve never attempted anything at that scale but couldn’t deny the behavior. I didn’t realize the base library was integer based. Maybe meant for processors without floating point units? Just speculating.

No, it’s done that way because floating point numbers in computers cause ALL KINDS of weirdness, and with integer values, it’s easier to exactly compare numbers, and if you store numerator and denominator, you can do very precise math with integers, it’s just awkward to use.

Computers, for example, can’t internally represent 0.1 as a binary floating point number - it’s either just a touch too large, or a touch too small, in the exact same way that 1/3 as a decimal can’t be exactly represented - 0.3333… is infinitely repeating, so you have to stop somewhere, and that limits precision, messes up calculations, and so on.