Beginner has trouble with intersection.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Beginner has trouble with intersection.

gg92507
This post has NOT been accepted by the mailing list yet.
Hello.  I am a beginner.  I am having trouble getting intersection() to do what I want in 2015.3.  I use the following code--

intersection(){
    cube(1);
    intersection(){
        cube(2);
        translate([0,0,10])cube(1);
    }
}

It gives me a little cube instead of what I want, which is nothing.  Release notes for 2014.3 says a similar bug was fixed, but on both 2014.3 and 2015.3, I get a little cube instead of nothing.

Is this the same bug or am I misunderstanding something?  What am I doing wrong?  Please help.  Am I using the wrong version of libcgal?  I am using libCGAL.so.10.0.4 from debian jessie.

Also, as a feature, I would like to specify cones.  For example, cone(){a(); b();} should be the union of all line segments with one endpoint in a() and one endpoint in b().  It is similar to hull(), but a little different if a() or b() is not convex.  cone(){a(); b(); c();} = cone(){a();cone(){b();c();}}, etc.
Reply | Threaded
Open this post in threaded view
|

Re: Beginner has trouble with intersection.

David Eccles (gringer)
gg92507 wrote
Hello.  I am a beginner.  I am having trouble getting intersection() to do what I want in 2015.3.  I use the following code--

intersection(){
    cube(1);
    intersection(){
        cube(2);
        translate([0,0,10])cube(1);
    }
}

It gives me a little cube instead of what I want, which is nothing.
All of the OpenSCAD set operations will work with a single construction, returning that construction. My guess at what is happening here is that the empty second intersection result is being treated as "no further arguments", rather than an argument of an empty construction.
Reply | Threaded
Open this post in threaded view
|

Re: Beginner has trouble with intersection.

hagen
In reply to this post by gg92507
preview (F5 on Windows) shows a cube, but render (F6) does not.
Reply | Threaded
Open this post in threaded view
|

Re: Beginner has trouble with intersection.

PolyVinalDistillate
Interesting that F5 and F6 give different results. The situation must be something like:

intersection()              //This intersection is interpreted by F5 as cube(1). The empty intersection
{                              //below cube(1) is disgarded because it represents no geometry, therefore
  cube(1);                  //we have an intersection of a cube only, = cube. F6 appears to actually intersect the
                               //cube with the null-geometry, resulting in nothing.

  intersection()               //this intersection equates to nothing because cubes don't overlap. F5 must
  {                               //disgard it completely from the geometry tree, while F6 keeps it in the tree
    cube(2);                   //as empty geometry allowing it to be used in further CSG
    translate([0,0,10])cube(1);
  }

}
Reply | Threaded
Open this post in threaded view
|

Re: Beginner has trouble with intersection.

kintel
Administrator
In reply to this post by gg92507
This is a known bug: https://github.com/openscad/openscad/issues/666

The result should be empty.