Haskell-Things / ImplicitCAD

A math-inspired CAD program in haskell. CSG, bevels, and shells; 2D & 3D geometry; 2D gcode generation...
https://implicitcad.org/
GNU Affero General Public License v3.0
1.39k stars 142 forks source link

Compiling examples produces "broken" geometry #170

Closed pulsar256 closed 4 years ago

pulsar256 commented 8 years ago

Affects 7d334a621810a8c55bbc7a17a343a6fc1c6e74d9 and the "stable" (0.0.5) release as available via cabal:

~  ᐅ cat test.escad
linear_extrude(height(x,y) = 20 + (y^2-x^2)/60)
  circle(30);
~  ᐅ extopenscad test.escad -o test.stl
Loading File.
Processing File.
Rendering 3D object to test.stl
With resolution 2.4021830874975945
In box ((-30.0,-30.0,0.0),(30.0,30.0,41.0))
ExtrudeRM 0.0 Nothing Nothing Nothing (Circle 30.0) (Right <function>)
~  ᐅ meshlab test.stl > /dev/null 2>&1 

Broken Geometry

Tried different resolutions and output types (obj), results were all the same.

julialongtin commented 8 years ago

Can you try the version at http://kalli1.faikvm.com/ImplicitCAD/Stable ?

pulsar256 commented 8 years ago

@julialongtin same results

Edit: Attached test-script and stl output. test.zip

~/development/Implicit_Stable (master ✔) ᐅ git rev-parse HEAD
b9ddf26c6e9a6104a831bb092c35afb02c84013d
~/development/Implicit_Stable (master ✔) ᐅ ls -lah $(which extopenscad)
-rwxr-xr-x 1 pulsar users 12M 21. Apr 10:14 /home/pulsar/.cabal/bin/extopenscad
ochafik commented 7 years ago

Is there any update on this? Bumping into the same issue as I'm running ImplicitCAD for the first time...

julialongtin commented 7 years ago

I'm still trying to hunt this down. more simple examples would be helpful.

wbrickner commented 7 years ago

Anything? A year later?

l29ah commented 6 years ago

Reproduced it on c597ee39074120a969b99404ba7ff56b598c6d4f. I expected changing ℝ to Float will affect it, but it haven't.

julialongtin commented 4 years ago

Fixed, at least temporarily. This is the same bug as #98 . The buggy optimization is commented out. Will close this issue, and leave #98 open, as a tracker to ensure the bug is fixed.

pulsar256 commented 4 years ago

Could you maybe point me to the commit with the workaround? Curious to see what fixed that. Maybe this is is something to learn from :)

julialongtin commented 4 years ago

https://github.com/colah/ImplicitCAD/commit/6e51e5f263d2cdedbdd230c107fd4c096f913f46

If you can figgure out what's wrong with the math, let me know! :)

pulsar256 commented 4 years ago

beats me, maybe it does affect gcc optimization in a way? Which makes me wonder if that could have been related to the issue. Seems there are a couple of flags which would sacrifice precision over performance (https://wiki.haskell.org/Performance/Floating_point) - but on the other hand, i would expect "rounding errors" to have a different manifestation.

julialongtin commented 4 years ago

yeah, i'll probably take a whack at this during a performance release.. until then...