Discussion:
[OpenSCAD] Smoother side on box
Mike Aubury
2018-11-12 12:32:32 UTC
Permalink
Hi,
this is probably some newbie thing, but I'm trying to design an insert for
a cars console.
Its got a slightly weird shape - but the outsides top/bottom etc are
roughly described by :

height=52.48;

boxPoints=[
[-135/2,0,0], // rear bottom left // 0
[135/2,0,0], // rear bottom right // 1
[145/2,202,0], // front bottom right // 2
[-145/2,202,0], // front bottom left // 3
[-137/2,-32.5,height], // rear top left // 4
[137/2,-32.5,height], // rear top right // 5
[171/2,202,height], // front top right //6
[-171/2,202,height], // front top left //7

];

boxFaces=[
[0,1,2,3], // bottom
[4,5,1,0], // front
[7,6,5,4], // top
[5,6,2,1], // right
[6,7,3,2], // back
[7,4,0,3] // left
];

polyhedron(boxPoints,boxFaces );



When I try to render this - on the two sides I get 2 triangle, which means
when I 3d printed it, I ended up with a bulge.
I'm assuming this needs to be some sort of curve rather than a single face,
but I've no idea how I'd go about coding for that..

Any ideas ?

Thanks in advance.
Kevin Toppenberg
2018-11-12 13:04:44 UTC
Permalink
On the end where y = ~0 ("bottom"), the sides are vertical. But on the end
where y = ~200 ("top"), the sides are beveled outward. I am assuming that
this is what you want. The 2 triangles are the simplest way for the engine
to achieve this description. I think one way to change this would to take
that side and divide it into 10 sub-parts. If that is the way you want to
go, I think I could help you calculate the sup-points making up the
sub-faces. But I have actually never worked with making polyhedrons, and
I'm not exactly sure how to layout the parts into the hole.

Kevin
Post by Mike Aubury
Hi,
this is probably some newbie thing, but I'm trying to design an insert
for a cars console.
Its got a slightly weird shape - but the outsides top/bottom etc are
height=52.48;
boxPoints=[
[-135/2,0,0], // rear bottom left // 0
[135/2,0,0], // rear bottom right // 1
[145/2,202,0], // front bottom right // 2
[-145/2,202,0], // front bottom left // 3
[-137/2,-32.5,height], // rear top left // 4
[137/2,-32.5,height], // rear top right // 5
[171/2,202,height], // front top right //6
[-171/2,202,height], // front top left //7
];
boxFaces=[
[0,1,2,3], // bottom
[4,5,1,0], // front
[7,6,5,4], // top
[5,6,2,1], // right
[6,7,3,2], // back
[7,4,0,3] // left
];
polyhedron(boxPoints,boxFaces );
When I try to render this - on the two sides I get 2 triangle, which means
when I 3d printed it, I ended up with a bulge.
I'm assuming this needs to be some sort of curve rather than a single
face, but I've no idea how I'd go about coding for that..
Any ideas ?
Thanks in advance.
_______________________________________________
OpenSCAD mailing list
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Kevin Toppenberg
2018-11-12 13:46:35 UTC
Permalink
Here is code that places points along the specified sides. It is an
intermediary step to a solution


height=52.48;

boxPoints=[
[-135/2,0,0], // rear bottom left // 0
[135/2,0,0], // rear bottom right // 1
[145/2,202,0], // front bottom right // 2
[-145/2,202,0], // front bottom left // 3
[-137/2,-32.5,height], // rear top left // 4
[137/2,-32.5,height], // rear top right // 5
[171/2,202,height], // front top right //6
[-171/2,202,height], // front top left //7

];

boxFaces=[
[0,1,2,3], // bottom
[4,5,1,0], // front
[7,6,5,4], // top
[5,6,2,1], // right
[6,7,3,2], // back
[7,4,0,3] // left
];

polyhedron(boxPoints,boxFaces );

//-------- added code ----------------

v1 = divided_line(boxPoints[0], boxPoints[3], 0.10);
for (i=[0:1:len(v1)-1]) translate(v1[i]) sphere(r=2);

v2 = divided_line(boxPoints[4], boxPoints[7], 0.10);
for (i=[0:1:len(v2)-1]) translate(v2[i]) sphere(r=2);

//return a array of points along line from p1 to p2
//step_pct should be value from 0 - 1 (e.g. 0.10) for points
// every 10% away along line
function divided_line(p1, p2, step_pct) = [for(pct =[0 : step_pct : 1]) p1
+ (p2-p1)*pct];

Kevin
Post by Kevin Toppenberg
On the end where y = ~0 ("bottom"), the sides are vertical. But on the
end where y = ~200 ("top"), the sides are beveled outward. I am assuming
that this is what you want. The 2 triangles are the simplest way for the
engine to achieve this description. I think one way to change this would
to take that side and divide it into 10 sub-parts. If that is the way you
want to go, I think I could help you calculate the sup-points making up the
sub-faces. But I have actually never worked with making polyhedrons, and
I'm not exactly sure how to layout the parts into the hole.
Kevin
Post by Mike Aubury
Hi,
this is probably some newbie thing, but I'm trying to design an insert
for a cars console.
Its got a slightly weird shape - but the outsides top/bottom etc are
height=52.48;
boxPoints=[
[-135/2,0,0], // rear bottom left // 0
[135/2,0,0], // rear bottom right // 1
[145/2,202,0], // front bottom right // 2
[-145/2,202,0], // front bottom left // 3
[-137/2,-32.5,height], // rear top left // 4
[137/2,-32.5,height], // rear top right // 5
[171/2,202,height], // front top right //6
[-171/2,202,height], // front top left //7
];
boxFaces=[
[0,1,2,3], // bottom
[4,5,1,0], // front
[7,6,5,4], // top
[5,6,2,1], // right
[6,7,3,2], // back
[7,4,0,3] // left
];
polyhedron(boxPoints,boxFaces );
When I try to render this - on the two sides I get 2 triangle, which
means when I 3d printed it, I ended up with a bulge.
I'm assuming this needs to be some sort of curve rather than a single
face, but I've no idea how I'd go about coding for that..
Any ideas ?
Thanks in advance.
_______________________________________________
OpenSCAD mailing list
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Mike Aubury
2018-11-12 14:37:15 UTC
Permalink
You're a genius :)
If I take your points and "hull" around them from one segment to the next..


segments=30;
v1 = divided_line(boxPoints[0], boxPoints[3], 1/segments);
v2 = divided_line(boxPoints[4], boxPoints[7], 1/segments);
v3 = divided_line(boxPoints[1], boxPoints[2], 1/segments);
v4 = divided_line(boxPoints[5], boxPoints[6], 1/segments);



for (i=[0:1:segments-1]) {
hull() {
translate(v1[i]) sphere(r=0.1);
translate(v2[i]) sphere(r=0.1);
translate(v3[i]) sphere(r=0.1);
translate(v4[i]) sphere(r=0.1);
translate(v1[i+1]) sphere(r=0.1);
translate(v2[i+1]) sphere(r=0.1);
translate(v3[i+1]) sphere(r=0.1);
translate(v4[i+1]) sphere(r=0.1);
}
}

seems to make it much neater :)
Post by Kevin Toppenberg
Here is code that places points along the specified sides. It is an
intermediary step to a solution
height=52.48;
boxPoints=[
[-135/2,0,0], // rear bottom left // 0
[135/2,0,0], // rear bottom right // 1
[145/2,202,0], // front bottom right // 2
[-145/2,202,0], // front bottom left // 3
[-137/2,-32.5,height], // rear top left // 4
[137/2,-32.5,height], // rear top right // 5
[171/2,202,height], // front top right //6
[-171/2,202,height], // front top left //7
];
boxFaces=[
[0,1,2,3], // bottom
[4,5,1,0], // front
[7,6,5,4], // top
[5,6,2,1], // right
[6,7,3,2], // back
[7,4,0,3] // left
];
polyhedron(boxPoints,boxFaces );
//-------- added code ----------------
v1 = divided_line(boxPoints[0], boxPoints[3], 0.10);
for (i=[0:1:len(v1)-1]) translate(v1[i]) sphere(r=2);
v2 = divided_line(boxPoints[4], boxPoints[7], 0.10);
for (i=[0:1:len(v2)-1]) translate(v2[i]) sphere(r=2);
//return a array of points along line from p1 to p2
//step_pct should be value from 0 - 1 (e.g. 0.10) for points
// every 10% away along line
function divided_line(p1, p2, step_pct) = [for(pct =[0 : step_pct : 1]) p1
+ (p2-p1)*pct];
Kevin
Post by Kevin Toppenberg
On the end where y = ~0 ("bottom"), the sides are vertical. But on the
end where y = ~200 ("top"), the sides are beveled outward. I am assuming
that this is what you want. The 2 triangles are the simplest way for the
engine to achieve this description. I think one way to change this would
to take that side and divide it into 10 sub-parts. If that is the way you
want to go, I think I could help you calculate the sup-points making up the
sub-faces. But I have actually never worked with making polyhedrons, and
I'm not exactly sure how to layout the parts into the hole.
Kevin
Post by Mike Aubury
Hi,
this is probably some newbie thing, but I'm trying to design an insert
for a cars console.
Its got a slightly weird shape - but the outsides top/bottom etc are
height=52.48;
boxPoints=[
[-135/2,0,0], // rear bottom left // 0
[135/2,0,0], // rear bottom right // 1
[145/2,202,0], // front bottom right // 2
[-145/2,202,0], // front bottom left // 3
[-137/2,-32.5,height], // rear top left // 4
[137/2,-32.5,height], // rear top right // 5
[171/2,202,height], // front top right //6
[-171/2,202,height], // front top left //7
];
boxFaces=[
[0,1,2,3], // bottom
[4,5,1,0], // front
[7,6,5,4], // top
[5,6,2,1], // right
[6,7,3,2], // back
[7,4,0,3] // left
];
polyhedron(boxPoints,boxFaces );
When I try to render this - on the two sides I get 2 triangle, which
means when I 3d printed it, I ended up with a bulge.
I'm assuming this needs to be some sort of curve rather than a single
face, but I've no idea how I'd go about coding for that..
Any ideas ?
Thanks in advance.
_______________________________________________
OpenSCAD mailing list
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Loading...