It’s pretty easy to deal with. I have a value “tiny = 1/128;” in all my code. Anywhere this is going to occur I expand the volume by tiny above the surface. It doesn’t matter that much but 1/128 is an exact value in binary and .01 is not.
-Bob
Tucson AZ
On Oct 7, 2022, at 09:26, Bogdan Caramalac via Discuss discuss@lists.openscad.org wrote:
From: fxeconomist@yahoo.com
Subject: [OpenSCAD] something upsets me about difference()
Date: October 7, 2022 at 09:26:14 MST
To: discuss@lists.openscad.org
Reply-To: OpenSCAD general discussion discuss@lists.openscad.org
It upsets me for quite a while.
Whenever I cut something, say with a cylinder, I always need to make it longer than the cut hole.
If I don’t, the hole is displayed on screen in a flipping on/off state, while if I make it longer by one unit, the hole appears integrally cut.
This creates an induced imprecision in most of the drawings.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Don’t know exactly how to take this. I tried it and there is a tiny difference, but somehow observable. I see a difference in drawing the edge of the cut.
On 10/7/2022 10:02 AM, Bob Carlson wrote:
It’s pretty easy to deal with. I have a value “tiny = 1/128;” in all
my code. Anywhere this is going to occur I expand the volume by tiny
above the surface. It doesn’t matter that much but 1/128 is an exact
value in binary and .01 is not.
I use two techniques.
Remember that in most cases the number doesn't have to be small.
Most of the time, I use +1. It's easy to type, and since I almost never
have actual numbers (versus variables) directly in the geometry it's
pretty obvious what's going on. Even in those rare cases where I have
actual numbers, it's even rarer that I have arithmetic on actual
numbers, so "5+1" is always five plus the differencing fudge factor.
(Especially since the "difference" verb gives a big hint.)
And remember where I said it usually doesn't have to be small? One
nuisance is in positioning the "drill", getting it properly aligned with
the surface to be drilled. If, for instance, you want to drill through
a block and your convenient reference point is the top, you have to
translate the cylinder down, or rotate it upside-down, or something.
And in either case, you have to take the fudge factor into account,
multiple times. That's all a nuisance. So don't do it. Make the
cylinder three times as tall as the thickness to be drilled, and center
it. No matter which direction you're drilling, that's enough to make it
through the object and have a fudge factor. (Technically, two-plus-a
little is enough, but "3" is easier to type.)
It happens that 1 and 3 are precise in binary math, but this is one
place where I think you should totally forget about binary math issues.
The precise values aren't going to matter, and so any mental effort
spent on binary math issues is wasted.