Quantcast

alternative to hull?

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

alternative to hull?

dkesler
Hi, and thank you already for thinking about helping. I need it!

This is a sculpture by Antoine Pevsner, that I've been trying to recreate.

Pevsner sculpture

A little inspiration (mostly perspiration) got me [x,y,z] coordinates for the end points of each of the straight lines. So I have an array with all the coordinates of the endpoints and here's what I've done:

Place spheres at the ends of a line.
Hull() them to make that line.
Place spheres at the ends of the next line.
Hull() them to make that next line.
Put n spheres at regular intervals along each line.
Hull() three at a time to make thick triangular faces to fill in the space between the skew lines.
Repeat with the second line and the third line.
And so on.

So admittedly it's a ton of lines and hull() ing to do, and I'm not surprised that it takes a while given my slow computer, but I'm hoping someone can say something like, "Erik worked on this three years ago, ask him," or, "try switching this with that or looping this other way." I'm improving the code kind of steadily, but when I have to wait three hours for the lowest of the lowest quality renderings, I lose a little steam. When it's done rendering, I get some steam back because the thing just looks so cool.



The only other idea I had was to individually crop and individually rotate individually twisted linearly extruded rectangles, but that math was scary to me compared to the nice loop I've got I've got below.

 I set up the code below to handle two lines and do it with fairly good looks. If you have a minute to render it and think about how *you'd* do it that might be faster or more efficient, I'd truly appreciate any feedback. It takes about 45 seconds to render on my laptop (Lenovo Thinkpad X201T, dual i7). It's no speed demon and doesn't have anything really special.

Thanks if you feel like helping! Drew


//beginning of abridged code

module web(p1,p2,p3,p4,slabs){
$fn=8;
hull(){
    translate(p1)    //places spheres at line
        sphere(.2);  //ends to be hulled
    translate(p2)
        sphere(.2);}
hull(){
    translate(p3)    //places spheres at line
        sphere(.2);  //ends to be hulled
    translate(p4)
        sphere(.2);}

/* This next loop places smaller spheres at even intervals along each line. It hulls three spheres (two from one side and one from the other) to create a triangular face, and then it hulls two from the other side and one from this side, etc, and works its way up the gap.*/
       
for (n=[1:1:slabs]){
    hull(){
        translate([p1[0]+(n-1)*(p2[0]-p1[0])/slabs,p1[1]+(n-1)*(p2[1]-p1[1])/slabs,p1[2]+(n-1)*(p2[2]-p1[2])/slabs])
            sphere(.1);
        translate([p3[0]+(n-1)*(p4[0]-p3[0])/slabs,p3[1]+(n-1)*(p4[1]-p3[1])/slabs,p3[2]+(n-1)*(p4[2]-p3[2])/slabs])
            sphere(.1);
        translate([p3[0]+n*(p4[0]-p3[0])/slabs,p3[1]+n*(p4[1]-p3[1])/slabs,p3[2]+n*(p4[2]-p3[2])/slabs])
            sphere(.1);}
    hull(){
        translate([p1[0]+(n-1)*(p2[0]-p1[0])/slabs,p1[1]+(n-1)*(p2[1]-p1[1])/slabs,p1[2]+(n-1)*(p2[2]-p1[2])/slabs])
            sphere(.1);
        translate([p1[0]+n*(p2[0]-p1[0])/slabs,p1[1]+n*(p2[1]-p1[1])/slabs,p1[2]+n*(p2[2]-p1[2])/slabs])
            sphere(.1);
        translate([p3[0]+n*(p4[0]-p3[0])/slabs,p3[1]+n*(p4[1]-p3[1])/slabs,p3[2]+n*(p4[2]-p3[2])/slabs])
            sphere(.1);}}}
           
 web(p1=[0,0,0],p2=[-2,3,10],p3=[3,3,-5],p4=[12,0,12],slabs=32);
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: alternative to hull?

Ronaldo
I would follow a very different path: polyhedron. However, it is very hard to sew all faces of a polyhedron. So I would use something like Parkinbot's sweep (see http://www.thingiverse.com/thing:900137). You will have to compute points but the render will be very quick. 

Em 16 de fev de 2017 01:35, "dkesler" <[hidden email]> escreveu:
Hi, and thank you already for thinking about helping. I need it!

This is a sculpture by Antoine Pevsner, that I've been trying to recreate.

<http://forum.openscad.org/file/n20461/IMG_3113.jpg>

A little inspiration (mostly perspiration) got me [x,y,z] coordinates for
the end points of each of the straight lines. So I have an array with all
the coordinates of the endpoints and here's what I've done:

Place spheres at the ends of a line.
Hull() them to make that line.
Place spheres at the ends of the next line.
Hull() them to make that next line.
Put n spheres at regular intervals along each line.
Hull() three at a time to make thick triangular faces to fill in the space
between the skew lines.
Repeat with the second line and the third line.
And so on.

So admittedly it's a ton of lines and hull() ing to do, and I'm not
surprised that it takes a while given my slow computer, but I'm hoping
someone can say something like, "Erik worked on this three years ago, ask
him," or, "try switching this with that or looping this other way." I'm
improving the code kind of steadily, but when I have to wait three hours for
the lowest of the lowest quality renderings, I lose a little steam. When
it's done rendering, I get some steam back because the thing just looks so
cool.

<http://forum.openscad.org/file/n20461/pevsner2.jpg>

The only other idea I had was to individually crop and individually rotate
individually twisted linearly extruded rectangles, but that math was scary
to me compared to the nice loop I've got I've got below.

 I set up the code below to handle two lines and do it with fairly good
looks. If you have a minute to render it and think about how *you'd* do it
that might be faster or more efficient, I'd truly appreciate any feedback.
It takes about 45 seconds to render on my laptop (Lenovo Thinkpad X201T,
dual i7). It's no speed demon and doesn't have anything really special.

Thanks if you feel like helping! Drew


//beginning of abridged code

module web(p1,p2,p3,p4,slabs){
$fn=8;
hull(){
    translate(p1)    //places spheres at line
        sphere(.2);  //ends to be hulled
    translate(p2)
        sphere(.2);}
hull(){
    translate(p3)    //places spheres at line
        sphere(.2);  //ends to be hulled
    translate(p4)
        sphere(.2);}

/* This next loop places smaller spheres at even intervals along each line.
It hulls three spheres (two from one side and one from the other) to create
a triangular face, and then it hulls two from the other side and one from
this side, etc, and works its way up the gap.*/

for (n=[1:1:slabs]){
    hull(){

translate([p1[0]+(n-1)*(p2[0]-p1[0])/slabs,p1[1]+(n-1)*(p2[1]-p1[1])/slabs,p1[2]+(n-1)*(p2[2]-p1[2])/slabs])
            sphere(.1);

translate([p3[0]+(n-1)*(p4[0]-p3[0])/slabs,p3[1]+(n-1)*(p4[1]-p3[1])/slabs,p3[2]+(n-1)*(p4[2]-p3[2])/slabs])
            sphere(.1);

translate([p3[0]+n*(p4[0]-p3[0])/slabs,p3[1]+n*(p4[1]-p3[1])/slabs,p3[2]+n*(p4[2]-p3[2])/slabs])
            sphere(.1);}
    hull(){

translate([p1[0]+(n-1)*(p2[0]-p1[0])/slabs,p1[1]+(n-1)*(p2[1]-p1[1])/slabs,p1[2]+(n-1)*(p2[2]-p1[2])/slabs])
            sphere(.1);

translate([p1[0]+n*(p2[0]-p1[0])/slabs,p1[1]+n*(p2[1]-p1[1])/slabs,p1[2]+n*(p2[2]-p1[2])/slabs])
            sphere(.1);

translate([p3[0]+n*(p4[0]-p3[0])/slabs,p3[1]+n*(p4[1]-p3[1])/slabs,p3[2]+n*(p4[2]-p3[2])/slabs])
            sphere(.1);}}}

 web(p1=[0,0,0],p2=[-2,3,10],p3=[3,3,-5],p4=[12,0,12],slabs=32);



--
View this message in context: http://forum.openscad.org/alternative-to-hull-tp20461.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: alternative to hull?

dkesler
Thanks Ronaldo,

I've been working on using polyhedron, but it's taking me a while since two polyhedra can't share an edge! So I'm using all kinds of cross products to push the edges apart.

I looked at sweep. I'll try that if I'm not good enough with the polyhedra math. Rendering sure is fast, though, so thanks a lot!

-Drew

On Feb 15, 2017, at 11:47 PM, Ronaldo [via OpenSCAD] <[hidden email]> wrote:

I would follow a very different path: polyhedron. However, it is very hard to sew all faces of a polyhedron. So I would use something like Parkinbot's sweep (see http://www.thingiverse.com/thing:900137). You will have to compute points but the render will be very quick. 

Em 16 de fev de 2017 01:35, "dkesler" <[hidden email]> escreveu:
Hi, and thank you already for thinking about helping. I need it!

This is a sculpture by Antoine Pevsner, that I've been trying to recreate.

<http://forum.openscad.org/file/n20461/IMG_3113.jpg>

A little inspiration (mostly perspiration) got me [x,y,z] coordinates for
the end points of each of the straight lines. So I have an array with all
the coordinates of the endpoints and here's what I've done:

Place spheres at the ends of a line.
Hull() them to make that line.
Place spheres at the ends of the next line.
Hull() them to make that next line.
Put n spheres at regular intervals along each line.
Hull() three at a time to make thick triangular faces to fill in the space
between the skew lines.
Repeat with the second line and the third line.
And so on.

So admittedly it's a ton of lines and hull() ing to do, and I'm not
surprised that it takes a while given my slow computer, but I'm hoping
someone can say something like, "Erik worked on this three years ago, ask
him," or, "try switching this with that or looping this other way." I'm
improving the code kind of steadily, but when I have to wait three hours for
the lowest of the lowest quality renderings, I lose a little steam. When
it's done rendering, I get some steam back because the thing just looks so
cool.

<http://forum.openscad.org/file/n20461/pevsner2.jpg>

The only other idea I had was to individually crop and individually rotate
individually twisted linearly extruded rectangles, but that math was scary
to me compared to the nice loop I've got I've got below.

 I set up the code below to handle two lines and do it with fairly good
looks. If you have a minute to render it and think about how *you'd* do it
that might be faster or more efficient, I'd truly appreciate any feedback.
It takes about 45 seconds to render on my laptop (Lenovo Thinkpad X201T,
dual i7). It's no speed demon and doesn't have anything really special.

Thanks if you feel like helping! Drew


//beginning of abridged code

module web(p1,p2,p3,p4,slabs){
$fn=8;
hull(){
    translate(p1)    //places spheres at line
        sphere(.2);  //ends to be hulled
    translate(p2)
        sphere(.2);}
hull(){
    translate(p3)    //places spheres at line
        sphere(.2);  //ends to be hulled
    translate(p4)
        sphere(.2);}

/* This next loop places smaller spheres at even intervals along each line.
It hulls three spheres (two from one side and one from the other) to create
a triangular face, and then it hulls two from the other side and one from
this side, etc, and works its way up the gap.*/

for (n=[1:1:slabs]){
    hull(){

translate([p1[0]+(n-1)*(p2[0]-p1[0])/slabs,p1[1]+(n-1)*(p2[1]-p1[1])/slabs,p1[2]+(n-1)*(p2[2]-p1[2])/slabs])
            sphere(.1);

translate([p3[0]+(n-1)*(p4[0]-p3[0])/slabs,p3[1]+(n-1)*(p4[1]-p3[1])/slabs,p3[2]+(n-1)*(p4[2]-p3[2])/slabs])
            sphere(.1);

translate([p3[0]+n*(p4[0]-p3[0])/slabs,p3[1]+n*(p4[1]-p3[1])/slabs,p3[2]+n*(p4[2]-p3[2])/slabs])
            sphere(.1);}
    hull(){

translate([p1[0]+(n-1)*(p2[0]-p1[0])/slabs,p1[1]+(n-1)*(p2[1]-p1[1])/slabs,p1[2]+(n-1)*(p2[2]-p1[2])/slabs])
            sphere(.1);

translate([p1[0]+n*(p2[0]-p1[0])/slabs,p1[1]+n*(p2[1]-p1[1])/slabs,p1[2]+n*(p2[2]-p1[2])/slabs])
            sphere(.1);

translate([p3[0]+n*(p4[0]-p3[0])/slabs,p3[1]+n*(p4[1]-p3[1])/slabs,p3[2]+n*(p4[2]-p3[2])/slabs])
            sphere(.1);}}}

 web(p1=[0,0,0],p2=[-2,3,10],p3=[3,3,-5],p4=[12,0,12],slabs=32);



--
View this message in context: http://forum.openscad.org/alternative-to-hull-tp20461.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/alternative-to-hull-tp20461p20462.html
To unsubscribe from alternative to hull?, click here.
NAML
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: alternative to hull?

Ronaldo
The idea is to define just one polyhedron for the whole model otherwise the union will be lengthy. 

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: alternative to hull?

Parkinbot
Here some example code for inspiration. I used only two polygons. To get a better and smoother tesselation of the winding plancs (and less problems with self-intersections), the trajectory should be described with a more resonable number of polygons.  

use <Naca_sweep.scad> // http://www.thingiverse.com/thing:900137

start = vec3D(gendat_2D(L=100)); // starting shape
end = Rz_(-70,  // in this specific case better work with negative angle to avoid self-intersection
      Tz_(90,   // translate
      vec3D(gendat_2D(L=200))));
trajectory =  [end, start];
sweep(trajectory);  // extrusion, check results with F5/F12, no purple allowed

// generate 2D shape of N planks to be extruded
function gendat_2D(N = 20, L=100, D=3, d=1, r=1) =  
  let(l = L/N, one=[[0, d/2], [r/2, d/2], [r, D/2],[l-r/2, D/2], [l, d/2]])
  concat ([for(i=[0:N-1], j=[0:len(one)-1]) [one[j][0]+l*i, -one[j][1]]],
          [for(i=[N-1:-1:0], j=[len(one)-1:-1:0]) [one[j][0]+l*i, one[j][1]]]);
Loading...