[OpenSCAD] General approach

Rogier Wolff R.E.Wolff at BitWizard.nl
Tue Jul 9 08:06:25 EDT 2019

On Mon, Jul 08, 2019 at 05:13:15PM +0100, nop head wrote:
> You get rounding errors because it is impossible to represent exact
> rotations numerically on a digital computer. Of course it is accurate
> enough for real life but you can't rely vertex positions exactly meeting
> for example.

rotate (2) cube (10);

I have now represented a rotation with numbers (numerically) on a
digital computer (mine, yours currently in your Email program or maybe

But yes, that "2" represents 2 degrees, which for technical reasons
needs to be in radians ASAP. Then it becomes irrational. And most of
the vertices of the cube move to irrational coordinates. 

For an example of "not exactly meeting": 

Suppose I do something like: 
  rotate (30) {
     for (i=[0:10:60])
        rotate (i) cube (10);

now onthe last object you'd think it's rotated by 90 degrees but in fact
its 30+60. Each of which was at one point converted to radians, rounded to 
the nearest double and then used to do trigonometry functions... 

In fact in this case I know that 30 and 60 in radians will be rounded
precisely in the same direction: in floating point only the exponent
differs. Thus the tolerance on the 90 degrees is even larger. And now
that rotation is no longer precisely 90 degrees.... 


** R.E.Wolff at BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

More information about the Discuss mailing list