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.41k stars 142 forks source link

Strange behaviour of the rounded union #204

Open elimohl opened 6 years ago

elimohl commented 6 years ago

The union of two rectangles: squares

I expected the rounded union be something like want

But actually I get this:

union(r=10) {
    square([10, 10]);
    translate([10, 0])
        square([10, 20]);
}

sample

elimohl commented 6 years ago
union(r=10) {
    square([10, 10]);
    translate([10, -5])
        square([10, 20]);
}

sample2

TLC123 commented 6 years ago

The rounding does not take in count the gradient normal of the two fields where they meet

On Sat, 26 May 2018, 11:27 Elizaveta Logacheva, notifications@github.com wrote:

union(r=10) { square([10, 10]); translate([10, -5]) square([10, 20]); }

[image: sample2] https://user-images.githubusercontent.com/10729543/40574732-12c95bb6-60e0-11e8-80c2-cfa1dcd72325.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/colah/ImplicitCAD/issues/204#issuecomment-392249456, or mute the thread https://github.com/notifications/unsubscribe-auth/AKcAaYg9_RbTO-bSp1aF2JSbBOQ_D2xHks5t2R_0gaJpZM4UO1-L .

Renha commented 6 years ago

@TLC123 why?

l29ah commented 5 years ago

Also occurs with 3D objects:

l29ah commented 5 years ago

The culprit is

getImplicit2 (UnionR2 r symbObjs) =
    \p -> let
        objs = map getImplicit2 symbObjs
    in
        if r == 0
        then minimum $ map ($p) objs
        else rminimum r $ map ($p) objs

I don't really understand how is it supposed to work though, and it feels to me that it's not enough to know the distances from a point to each of the objects to find the distance to the rounded union of the objects.

l29ah commented 5 years ago

Reading https://christopherolah.wordpress.com/2011/11/06/manipulation-of-implicit-functions-with-an-eye-on-cad/

(NB. This particular formation of rounded unions is a little bit naive. If you union and the sides aren’t orthogonal, this version will make a bump, which is not the expected behavior. This can be corrected for quite easily by looking at the dot product of the discrete gradients.)

I have no idea how to do this w/o explosive computational complexity growth.

julialongtin commented 3 years ago

still present.

julialongtin commented 3 years ago

hmm. still present.