Another polyhedron with missing faces

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

Another polyhedron with missing faces

AndreasG4r
Hello,

I think I have missing faces in my polyhedron because I am unable to compute
a difference or something similar with an other object.
However, the plain polyhedron looks fine so I don't know where my bug is
located.

Thank you very much for your help.
Andreas



lenX=100;
lenY=200;
sizeX = 100;
sizeY = 100;
lenTot=lenX*lenY;
cntX=3;
cntY=5;
amplitude=10;
wallSize=3;
function generator(x,y) =
amplitude*sin(x*360*cntX/lenX)*sin(y*360*cntY/lenY);
function p(x,y,z) = x+y*lenX+z*lenX*lenY;

// x1y1 x1y2 x1y3, ... , x2y1, ...
//Start 2. X Point 2
//Start 2. Y Point lenX
//Start 2. Level: lenX*lenY
points = [
    for(y = [0:lenY-1]) for(x = [0:lenX-1])
[x*sizeX/lenX,y*sizeY/lenY,generator(x,y) - wallSize/2] ,
    for(y = [0:lenY-1]) for(x = [0:lenX-1])
[x*sizeX/lenX,y*sizeY/lenY,generator(x,y) + wallSize/2],
        ];
faces = [
    for(x = [0:lenX-2]) for(y = [0:lenY-2])
[p(x,y,0),p(x,y+1,0),p(x+1,y+1,0),p(x+1,y,0)],
    for(x = [0:lenX-2]) for(y = [0:lenY-2])
[p(x,y,1),p(x,y+1,1),p(x+1,y+1,1),p(x+1,y,1)],
    for(x = [0:lenX-2]) [p(x,0,0),p(x+1,0,0),p(x+1,0,1),p(x,0,1)],
    for(x = [0:lenX-2])
[p(x,lenY-1,0),p(x+1,lenY-1,0),p(x+1,lenY-1,1),p(x,lenY-1,1)],
    for(y = [0:lenY-2]) [p(0,y,0),p(0,y+1,0),p(0,y+1,1),p(0,y,1)],
    for(y = [0:lenY-2])
[p(lenX-1,y,0),p(lenX-1,y+1,0),p(lenX-1,y+1,1),p(lenX-1,y,1)],
       
];

difference(){
    polyhedron(points,faces,convexity = 20);
    cube([sizeX/2,sizeY/2,wallSize*10]);
}



--
Sent from: http://forum.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
|

Re: Another polyhedron with missing faces

thehans

On Wed, Dec 4, 2019 at 12:12 AM AndreasG4r <[hidden email]> wrote:
Hello,

I think I have missing faces in my polyhedron because I am unable to compute
a difference or something similar with an other object.
However, the plain polyhedron looks fine so I don't know where my bug is
located.

Thank you very much for your help.
Andreas



lenX=100;
lenY=200;
sizeX = 100;
sizeY = 100;
lenTot=lenX*lenY;
cntX=3;
cntY=5;
amplitude=10;
wallSize=3;
function generator(x,y) =
amplitude*sin(x*360*cntX/lenX)*sin(y*360*cntY/lenY);
function p(x,y,z) = x+y*lenX+z*lenX*lenY;

// x1y1 x1y2 x1y3, ... , x2y1, ...
//Start 2. X Point 2
//Start 2. Y Point lenX
//Start 2. Level: lenX*lenY
points = [
    for(y = [0:lenY-1]) for(x = [0:lenX-1])
[x*sizeX/lenX,y*sizeY/lenY,generator(x,y) - wallSize/2] ,
    for(y = [0:lenY-1]) for(x = [0:lenX-1])
[x*sizeX/lenX,y*sizeY/lenY,generator(x,y) + wallSize/2],
        ];
faces = [
    for(x = [0:lenX-2]) for(y = [0:lenY-2])
[p(x,y,0),p(x,y+1,0),p(x+1,y+1,0),p(x+1,y,0)],
    for(x = [0:lenX-2]) for(y = [0:lenY-2])
[p(x,y,1),p(x,y+1,1),p(x+1,y+1,1),p(x+1,y,1)],
    for(x = [0:lenX-2]) [p(x,0,0),p(x+1,0,0),p(x+1,0,1),p(x,0,1)],
    for(x = [0:lenX-2])
[p(x,lenY-1,0),p(x+1,lenY-1,0),p(x+1,lenY-1,1),p(x,lenY-1,1)],
    for(y = [0:lenY-2]) [p(0,y,0),p(0,y+1,0),p(0,y+1,1),p(0,y,1)],
    for(y = [0:lenY-2])
[p(lenX-1,y,0),p(lenX-1,y+1,0),p(lenX-1,y+1,1),p(lenX-1,y,1)],

];

difference(){
    polyhedron(points,faces,convexity = 20);
    cube([sizeX/2,sizeY/2,wallSize*10]);
}



--
Sent from: http://forum.openscad.org/

_______________________________________________
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
|

Re: Another polyhedron with missing faces

Ronaldo
In reply to this post by AndreasG4r
eggbox.PNG

Em qua., 4 de dez. de 2019 às 06:12, AndreasG4r <[hidden email]> escreveu:
Hello,

I think I have missing faces in my polyhedron because I am unable to compute
a difference or something similar with an other object.
However, the plain polyhedron looks fine so I don't know where my bug is
located.

Thank you very much for your help.
Andreas



lenX=100;
lenY=200;
sizeX = 100;
sizeY = 100;
lenTot=lenX*lenY;
cntX=3;
cntY=5;
amplitude=10;
wallSize=3;
function generator(x,y) =
amplitude*sin(x*360*cntX/lenX)*sin(y*360*cntY/lenY);
function p(x,y,z) = x+y*lenX+z*lenX*lenY;

// x1y1 x1y2 x1y3, ... , x2y1, ...
//Start 2. X Point 2
//Start 2. Y Point lenX
//Start 2. Level: lenX*lenY
points = [
    for(y = [0:lenY-1]) for(x = [0:lenX-1])
[x*sizeX/lenX,y*sizeY/lenY,generator(x,y) - wallSize/2] ,
    for(y = [0:lenY-1]) for(x = [0:lenX-1])
[x*sizeX/lenX,y*sizeY/lenY,generator(x,y) + wallSize/2],
        ];
faces = [
    for(x = [0:lenX-2]) for(y = [0:lenY-2])
[p(x,y,0),p(x,y+1,0),p(x+1,y+1,0),p(x+1,y,0)],
    for(x = [0:lenX-2]) for(y = [0:lenY-2])
[p(x,y,1),p(x,y+1,1),p(x+1,y+1,1),p(x+1,y,1)],
    for(x = [0:lenX-2]) [p(x,0,0),p(x+1,0,0),p(x+1,0,1),p(x,0,1)],
    for(x = [0:lenX-2])
[p(x,lenY-1,0),p(x+1,lenY-1,0),p(x+1,lenY-1,1),p(x,lenY-1,1)],
    for(y = [0:lenY-2]) [p(0,y,0),p(0,y+1,0),p(0,y+1,1),p(0,y,1)],
    for(y = [0:lenY-2])
[p(lenX-1,y,0),p(lenX-1,y+1,0),p(lenX-1,y+1,1),p(lenX-1,y,1)],

];

difference(){
    polyhedron(points,faces,convexity = 20);
    cube([sizeX/2,sizeY/2,wallSize*10]);
}



--
Sent from: http://forum.openscad.org/

_______________________________________________
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
|

Re: Another polyhedron with missing faces

AndreasG4r
In reply to this post by thehans
Thank you very much for your comments.
Now I got it. I don't have missing faces - I have wrong oriented faces.
And I learned a new feature of the editor :)

Just in case someone needs something like this:



lenX=100;
lenY=200;
sizeX = 100;
sizeY = 100;
lenTot=lenX*lenY;
cntX=3;
cntY=5;
amplitude=10;
wallSize=3;
function generator(x,y) =
amplitude*sin(x*360*cntX/lenX)*sin(y*360*cntY/lenY);
function p(x,y,z) = x+y*lenX+z*lenX*lenY;


//for(x = [0:100])
//for(y = [0:100])
//translate([x,y,generator(x,y)])
//sphere(r=3);


// x1y1 x1y2 x1y3, ... , x2y1, ...
//Start 2. X Punkt 2
//Start 2. Y Punkt lenX
//Start 2. Ebene: lenX*lenY
points = [
    for(y = [0:lenY-1]) for(x = [0:lenX-1])
[x*sizeX/lenX,y*sizeY/lenY,generator(x,y) - wallSize/2] ,
    for(y = [0:lenY-1]) for(x = [0:lenX-1])
[x*sizeX/lenX,y*sizeY/lenY,generator(x,y) + wallSize/2],
        ];
faces = [
    for(x = [0:lenX-2]) for(y = [0:lenY-2])
[p(x,y,0),p(x+1,y,0),p(x+1,y+1,0),p(x,y+1,0)],
    for(x = [0:lenX-2]) for(y = [0:lenY-2])
[p(x,y,1),p(x,y+1,1),p(x+1,y+1,1),p(x+1,y,1)],
    for(x = [0:lenX-2]) [p(x,0,0),p(x,0,1),p(x+1,0,1),p(x+1,0,0)],
    for(x = [0:lenX-2])
[p(x,lenY-1,0),p(x+1,lenY-1,0),p(x+1,lenY-1,1),p(x,lenY-1,1)],
    for(y = [0:lenY-2]) [p(0,y,0),p(0,y+1,0),p(0,y+1,1),p(0,y,1)],
    for(y = [0:lenY-2])
[p(lenX-1,y,0),p(lenX-1,y,1),p(lenX-1,y+1,1),p(lenX-1,y+1,0)],
       
];

intersection(){
    polyhedron(points,faces,convexity = 20);
    translate([0,0,-1]*(wallSize))
    cube([sizeX,sizeY,wallSize*2]);
}



--
Sent from: http://forum.openscad.org/

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