discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

intersecting with an hyperbola

P
Parkinbot
Thu, Dec 24, 2015 4:56 AM

ah,... you are the guy with the potatoe chip.

Sorry, got your specification wrong.

  • calc points of upper and lower surface
  • calc triangles of upper and lower surface
  • calc triangles of border

Good idea to cut the square plot with a sphere!

http://forum.openscad.org/file/n15307/showcase13.png

I guess this is your code:

N = 140;
range = [for (i=[0:N-1]) -1+i*2/(N-1)];

upper = point_function(range, .1);  // upper face
lower = point_function(range, 0);  // lower face

Faces = concat(
triangles(N, upper),
triangles(N, lower, true),
triangles_border(N));

Points = concat(upper, lower);

intersection()
{
sphere(1, $fn = 100);
polyhedron(faces = Faces, points = Points, convexity=3);
}

function point_function(range, dz) =
[for(i=range) for(j=range) [i,j,i*j+dz]];

function triangles(N, A, offs = false) =  // triangles of area
let (M = offs?N*N:0)
[for (i=[M:M+len(A)-N-1], j = [1,0])
if(((i+1)%N)>0)
offs?
j?[i+N, i+N+1, i+1 ]:[i+N, i+1, i]:
j?[i+N, i, i+1]    :[i+N, i+1, i+N+1]
];

function triangles_border(N) =  // triangles of border
let (M = N*N)
let (I = borderIndex(N))
let (end = I[len(I)-1])
concat([[0, end, M], [end, end+M, M]], // last square
[for(i = [0:len(I)-1], j=[0,1])
j?[I[i+1], I[i], M+I[i]]:[M+I[i+1], I[i+1], M+I[i]]]);

function borderIndex(N) =  // around the square
concat(
[for(i=[0:N-2]) i],        // side 1
[for(i=[N-1:N:NN-2]) i],  // side 2
[for(i=[N
N-1:-1:N*(N-1)+1])i ], // side 3
[for(i=[N*(N-1):-N:N]) i]  // // side 4
);

--
View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15307.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

ah,... you are the guy with the potatoe chip. Sorry, got your specification wrong. - calc points of upper and lower surface - calc triangles of upper and lower surface - calc triangles of border Good idea to cut the square plot with a sphere! <http://forum.openscad.org/file/n15307/showcase13.png> I guess this is your code: > N = 140; > range = [for (i=[0:N-1]) -1+i*2/(N-1)]; > > upper = point_function(range, .1); // upper face > lower = point_function(range, 0); // lower face > > Faces = concat( > triangles(N, upper), > triangles(N, lower, true), > triangles_border(N)); > > Points = concat(upper, lower); > > intersection() > { > sphere(1, $fn = 100); > polyhedron(faces = Faces, points = Points, convexity=3); > } > > function point_function(range, dz) = > [for(i=range) for(j=range) [i,j,i*j+dz]]; > > function triangles(N, A, offs = false) = // triangles of area > let (M = offs?N*N:0) > [for (i=[M:M+len(A)-N-1], j = [1,0]) > if(((i+1)%N)>0) > offs? > j?[i+N, i+N+1, i+1 ]:[i+N, i+1, i]: > j?[i+N, i, i+1] :[i+N, i+1, i+N+1] > ]; > > function triangles_border(N) = // triangles of border > let (M = N*N) > let (I = borderIndex(N)) > let (end = I[len(I)-1]) > concat([[0, end, M], [end, end+M, M]], // last square > [for(i = [0:len(I)-1], j=[0,1]) > j?[I[i+1], I[i], M+I[i]]:[M+I[i+1], I[i+1], M+I[i]]]); > > function borderIndex(N) = // around the square > concat( > [for(i=[0:N-2]) i], // side 1 > [for(i=[N-1:N:N*N-2]) i], // side 2 > [for(i=[N*N-1:-1:N*(N-1)+1])i ], // side 3 > [for(i=[N*(N-1):-N:N]) i] // // side 4 > ); > > -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15307.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Thu, Dec 24, 2015 6:07 AM

and having fun with thickness of chip :)
N = 40;
thick = 1;
sphere_res = 100;

range = [for (i=[0:N-1]) -1+i*2/(N-1)];

upper = point_function(range, thick);  // upper face
lower = point_function(range, 0);  // lower face

Faces = concat(
triangles(N, upper),
triangles(N, lower, true),
triangles_border(N));

Points = concat(upper, lower);

intersection()
{
translate([0,0,thick/2])
sphere(1, $fn = sphere_res);
polyhedron(faces = Faces, points = Points, convexity=3);
}

.. and the rest
gives
http://forum.openscad.org/file/n15308/sample-hyperbola.png

--
View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15308.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

and having fun with thickness of chip :) N = 40; thick = 1; sphere_res = 100; range = [for (i=[0:N-1]) -1+i*2/(N-1)]; upper = point_function(range, thick); // upper face lower = point_function(range, 0); // lower face Faces = concat( triangles(N, upper), triangles(N, lower, true), triangles_border(N)); Points = concat(upper, lower); intersection() { translate([0,0,thick/2]) sphere(1, $fn = sphere_res); polyhedron(faces = Faces, points = Points, convexity=3); } .. and the rest gives <http://forum.openscad.org/file/n15308/sample-hyperbola.png> -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15308.html Sent from the OpenSCAD mailing list archive at Nabble.com.
HL
Hans L
Thu, Dec 24, 2015 6:51 AM

I spent a little time refactoring and simplifying the 3d-function.scad
example today. Attached is my version of "The Pringles Code".

On Thu, Dec 24, 2015 at 12:07 AM, Neon22 mschafer@wireframe.biz wrote:

and having fun with thickness of chip :)
N = 40;
thick = 1;
sphere_res = 100;

range = [for (i=[0:N-1]) -1+i*2/(N-1)];

upper = point_function(range, thick);  // upper face
lower = point_function(range, 0);  // lower face

Faces = concat(
triangles(N, upper),
triangles(N, lower, true),
triangles_border(N));

Points = concat(upper, lower);

intersection()
{
translate([0,0,thick/2])
sphere(1, $fn = sphere_res);
polyhedron(faces = Faces, points = Points, convexity=3);
}

.. and the rest
gives
http://forum.openscad.org/file/n15308/sample-hyperbola.png

--
View this message in context:
http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15308.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I spent a little time refactoring and simplifying the 3d-function.scad example today. Attached is my version of "The Pringles Code". ​ On Thu, Dec 24, 2015 at 12:07 AM, Neon22 <mschafer@wireframe.biz> wrote: > and having fun with thickness of chip :) > N = 40; > thick = 1; > sphere_res = 100; > > range = [for (i=[0:N-1]) -1+i*2/(N-1)]; > > upper = point_function(range, thick); // upper face > lower = point_function(range, 0); // lower face > > Faces = concat( > triangles(N, upper), > triangles(N, lower, true), > triangles_border(N)); > > Points = concat(upper, lower); > > intersection() > { > translate([0,0,thick/2]) > sphere(1, $fn = sphere_res); > polyhedron(faces = Faces, points = Points, convexity=3); > } > > .. and the rest > gives > <http://forum.openscad.org/file/n15308/sample-hyperbola.png> > > > > -- > View this message in context: > http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15308.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
HL
Hans L
Thu, Dec 24, 2015 6:52 AM

Whoops, meant to attach this version

On Thu, Dec 24, 2015 at 12:51 AM, Hans L thehans@gmail.com wrote:

I spent a little time refactoring and simplifying the 3d-function.scad
example today. Attached is my version of "The Pringles Code".

On Thu, Dec 24, 2015 at 12:07 AM, Neon22 mschafer@wireframe.biz wrote:

and having fun with thickness of chip :)
N = 40;
thick = 1;
sphere_res = 100;

range = [for (i=[0:N-1]) -1+i*2/(N-1)];

upper = point_function(range, thick);  // upper face
lower = point_function(range, 0);  // lower face

Faces = concat(
triangles(N, upper),
triangles(N, lower, true),
triangles_border(N));

Points = concat(upper, lower);

intersection()
{
translate([0,0,thick/2])
sphere(1, $fn = sphere_res);
polyhedron(faces = Faces, points = Points, convexity=3);
}

.. and the rest
gives
http://forum.openscad.org/file/n15308/sample-hyperbola.png

--
View this message in context:
http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15308.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Whoops, meant to attach this version On Thu, Dec 24, 2015 at 12:51 AM, Hans L <thehans@gmail.com> wrote: > I spent a little time refactoring and simplifying the 3d-function.scad > example today. Attached is my version of "The Pringles Code". > > > ​ > > On Thu, Dec 24, 2015 at 12:07 AM, Neon22 <mschafer@wireframe.biz> wrote: > >> and having fun with thickness of chip :) >> N = 40; >> thick = 1; >> sphere_res = 100; >> >> range = [for (i=[0:N-1]) -1+i*2/(N-1)]; >> >> upper = point_function(range, thick); // upper face >> lower = point_function(range, 0); // lower face >> >> Faces = concat( >> triangles(N, upper), >> triangles(N, lower, true), >> triangles_border(N)); >> >> Points = concat(upper, lower); >> >> intersection() >> { >> translate([0,0,thick/2]) >> sphere(1, $fn = sphere_res); >> polyhedron(faces = Faces, points = Points, convexity=3); >> } >> >> .. and the rest >> gives >> <http://forum.openscad.org/file/n15308/sample-hyperbola.png> >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15308.html >> Sent from the OpenSCAD mailing list archive at Nabble.com. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > >
HL
Hans L
Thu, Dec 24, 2015 6:57 AM

Agh, there is a weird bug where it seems that opening other OpenSCAD
instances from other directiories causes subsequent saves to go to the
wrong directory.  Sorry, kept getting the wrong save of this file since I
was grabbing from my original save path.

On Thu, Dec 24, 2015 at 12:52 AM, Hans L thehans@gmail.com wrote:

Whoops, meant to attach this version

On Thu, Dec 24, 2015 at 12:51 AM, Hans L thehans@gmail.com wrote:

I spent a little time refactoring and simplifying the 3d-function.scad
example today. Attached is my version of "The Pringles Code".

On Thu, Dec 24, 2015 at 12:07 AM, Neon22 mschafer@wireframe.biz wrote:

and having fun with thickness of chip :)
N = 40;
thick = 1;
sphere_res = 100;

range = [for (i=[0:N-1]) -1+i*2/(N-1)];

upper = point_function(range, thick);  // upper face
lower = point_function(range, 0);  // lower face

Faces = concat(
triangles(N, upper),
triangles(N, lower, true),
triangles_border(N));

Points = concat(upper, lower);

intersection()
{
translate([0,0,thick/2])
sphere(1, $fn = sphere_res);
polyhedron(faces = Faces, points = Points, convexity=3);
}

.. and the rest
gives
http://forum.openscad.org/file/n15308/sample-hyperbola.png

--
View this message in context:
http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15308.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Agh, there is a weird bug where it seems that opening other OpenSCAD instances from other directiories causes subsequent saves to go to the wrong directory. Sorry, kept getting the wrong save of this file since I was grabbing from my original save path. On Thu, Dec 24, 2015 at 12:52 AM, Hans L <thehans@gmail.com> wrote: > Whoops, meant to attach this version > > On Thu, Dec 24, 2015 at 12:51 AM, Hans L <thehans@gmail.com> wrote: > >> I spent a little time refactoring and simplifying the 3d-function.scad >> example today. Attached is my version of "The Pringles Code". >> >> >> ​ >> >> On Thu, Dec 24, 2015 at 12:07 AM, Neon22 <mschafer@wireframe.biz> wrote: >> >>> and having fun with thickness of chip :) >>> N = 40; >>> thick = 1; >>> sphere_res = 100; >>> >>> range = [for (i=[0:N-1]) -1+i*2/(N-1)]; >>> >>> upper = point_function(range, thick); // upper face >>> lower = point_function(range, 0); // lower face >>> >>> Faces = concat( >>> triangles(N, upper), >>> triangles(N, lower, true), >>> triangles_border(N)); >>> >>> Points = concat(upper, lower); >>> >>> intersection() >>> { >>> translate([0,0,thick/2]) >>> sphere(1, $fn = sphere_res); >>> polyhedron(faces = Faces, points = Points, convexity=3); >>> } >>> >>> .. and the rest >>> gives >>> <http://forum.openscad.org/file/n15308/sample-hyperbola.png> >>> >>> >>> >>> -- >>> View this message in context: >>> http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15308.html >>> Sent from the OpenSCAD mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >> >> >
M
Mekko
Thu, Dec 24, 2015 7:45 AM

LOL. Actually, I'm not the potato chip guy - I'm just trying to cut a sphere
in half with an hyperbola and getting a potato chip instead.

Hopefully the true Potato Chip Guy is reading this thread though!

--
View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

LOL. Actually, I'm not the potato chip guy - I'm just trying to cut a sphere in half with an hyperbola and getting a potato chip instead. Hopefully the true Potato Chip Guy is reading this thread though! -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Thu, Dec 24, 2015 10:01 AM

Here is a version that finally works.


xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.05;
zmin = min(xmin *ymax, xmax * ymin);

xpoints = floor((xmax - xmin) / step) + 1;
ypoints = floor((ymax - ymin) / step) + 1;
function index(x,y) = x * ypoints + y + 2;
function x(i) = xmin + i * step;
function y(i) = ymin + i * step;

points = concat([[xmin, ymin, zmin]],
[[xmax, ymax, zmin]],
[for(i = [0 : xpoints - 1]) for(j = [0 : ypoints - 1]) [x(i),
y(j), x(i) * y(j)]]);

function flatten(l) = [for(a = l) for (b = a) b];

base = concat(
[[1, 0, index(xpoints - 1, 0)]],
[[0, 1, index(0, ypoints - 1)]],
[for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1, 0)]],
[for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0, j)]],
[for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), index(i,
ypoints - 1)]],
[for(j = [0 : ypoints - 2]) [1, index(xpoints - 1, j),
index(xpoints - 1, j + 1)]]
);

faces = flatten([for(i = [0 : xpoints - 2]) for(j = [0 : ypoints - 2])
[[index(i,j), index(i, j + 1), index(i + 1, j + 1)],
[index(i + 1, j + 1), index(i + 1, j ), index(i, j)]]
]);

difference() {
sphere(r= 0.5, $fn=80);
polyhedron(points, concat(base, faces), convexity = 2);
}

My stupid mistake was flattening the base list when it didn't need to be.
The result was some faces with multiple triangles instead of single
triangle per face. Looks like cgal can't handle that but the rest of the
system can. The STL file it exported was correct..

On 24 December 2015 at 07:45, Mekko serve@perdix.org wrote:

LOL. Actually, I'm not the potato chip guy - I'm just trying to cut a
sphere
in half with an hyperbola and getting a potato chip instead.

Hopefully the true Potato Chip Guy is reading this thread though!

--
View this message in context:
http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Here is a version that finally works. ​ xmin = -1; xmax = 1; ymin = -1; ymax = 1; step = 0.05; zmin = min(xmin *ymax, xmax * ymin); xpoints = floor((xmax - xmin) / step) + 1; ypoints = floor((ymax - ymin) / step) + 1; function index(x,y) = x * ypoints + y + 2; function x(i) = xmin + i * step; function y(i) = ymin + i * step; points = concat([[xmin, ymin, zmin]], [[xmax, ymax, zmin]], [for(i = [0 : xpoints - 1]) for(j = [0 : ypoints - 1]) [x(i), y(j), x(i) * y(j)]]); function flatten(l) = [for(a = l) for (b = a) b]; base = concat( [[1, 0, index(xpoints - 1, 0)]], [[0, 1, index(0, ypoints - 1)]], [for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1, 0)]], [for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0, j)]], [for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), index(i, ypoints - 1)]], [for(j = [0 : ypoints - 2]) [1, index(xpoints - 1, j), index(xpoints - 1, j + 1)]] ); faces = flatten([for(i = [0 : xpoints - 2]) for(j = [0 : ypoints - 2]) [[index(i,j), index(i, j + 1), index(i + 1, j + 1)], [index(i + 1, j + 1), index(i + 1, j ), index(i, j)]] ]); difference() { sphere(r= 0.5, $fn=80); polyhedron(points, concat(base, faces), convexity = 2); } ​ My stupid mistake was flattening the base list when it didn't need to be. The result was some faces with multiple triangles instead of single triangle per face. Looks like cgal can't handle that but the rest of the system can. The STL file it exported was correct.. On 24 December 2015 at 07:45, Mekko <serve@perdix.org> wrote: > LOL. Actually, I'm not the potato chip guy - I'm just trying to cut a > sphere > in half with an hyperbola and getting a potato chip instead. > > Hopefully the true Potato Chip Guy is reading this thread though! > > > > -- > View this message in context: > http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
AG
Alex Gibson
Thu, Dec 24, 2015 10:25 AM

Nice shape.  I just installed more RAM in my PC so fancy doing a minkowski sum of that with a sphere.  The room I’m working in needs warming up… J

From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head
Sent: 24 December 2015 10:02
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] intersecting with an hyperbola

Here is a version that finally works.


xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.05;
zmin = min(xmin *ymax, xmax * ymin);

xpoints = floor((xmax - xmin) / step) + 1;
ypoints = floor((ymax - ymin) / step) + 1;
function index(x,y) = x * ypoints + y + 2;
function x(i) = xmin + i * step;
function y(i) = ymin + i * step;

points = concat([[xmin, ymin, zmin]],
[[xmax, ymax, zmin]],
[for(i = [0 : xpoints - 1]) for(j = [0 : ypoints - 1]) [x(i), y(j), x(i) * y(j)]]);

function flatten(l) = [for(a = l) for (b = a) b];

base = concat(
[[1, 0, index(xpoints - 1, 0)]],
[[0, 1, index(0, ypoints - 1)]],
[for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1, 0)]],
[for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0, j)]],
[for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), index(i, ypoints - 1)]],
[for(j = [0 : ypoints - 2]) [1, index(xpoints - 1, j), index(xpoints - 1, j + 1)]]
);

faces = flatten([for(i = [0 : xpoints - 2]) for(j = [0 : ypoints - 2])
[[index(i,j), index(i, j + 1), index(i + 1, j + 1)],
[index(i + 1, j + 1), index(i + 1, j ), index(i, j)]]
]);

difference() {
sphere(r= 0.5, $fn=80);
polyhedron(points, concat(base, faces), convexity = 2);
}

My stupid mistake was flattening the base list when it didn't need to be. The result was some faces with multiple triangles instead of single triangle per face. Looks like cgal can't handle that but the rest of the system can. The STL file it exported was correct..

On 24 December 2015 at 07:45, Mekko serve@perdix.org wrote:

LOL. Actually, I'm not the potato chip guy - I'm just trying to cut a sphere
in half with an hyperbola and getting a potato chip instead.

Hopefully the true Potato Chip Guy is reading this thread though!

--
View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html

Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Nice shape. I just installed more RAM in my PC so fancy doing a minkowski sum of that with a sphere. The room I’m working in needs warming up… J From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head Sent: 24 December 2015 10:02 To: OpenSCAD general discussion Subject: Re: [OpenSCAD] intersecting with an hyperbola Here is a version that finally works. ​ xmin = -1; xmax = 1; ymin = -1; ymax = 1; step = 0.05; zmin = min(xmin *ymax, xmax * ymin); xpoints = floor((xmax - xmin) / step) + 1; ypoints = floor((ymax - ymin) / step) + 1; function index(x,y) = x * ypoints + y + 2; function x(i) = xmin + i * step; function y(i) = ymin + i * step; points = concat([[xmin, ymin, zmin]], [[xmax, ymax, zmin]], [for(i = [0 : xpoints - 1]) for(j = [0 : ypoints - 1]) [x(i), y(j), x(i) * y(j)]]); function flatten(l) = [for(a = l) for (b = a) b]; base = concat( [[1, 0, index(xpoints - 1, 0)]], [[0, 1, index(0, ypoints - 1)]], [for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1, 0)]], [for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0, j)]], [for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), index(i, ypoints - 1)]], [for(j = [0 : ypoints - 2]) [1, index(xpoints - 1, j), index(xpoints - 1, j + 1)]] ); faces = flatten([for(i = [0 : xpoints - 2]) for(j = [0 : ypoints - 2]) [[index(i,j), index(i, j + 1), index(i + 1, j + 1)], [index(i + 1, j + 1), index(i + 1, j ), index(i, j)]] ]); difference() { sphere(r= 0.5, $fn=80); polyhedron(points, concat(base, faces), convexity = 2); } ​ My stupid mistake was flattening the base list when it didn't need to be. The result was some faces with multiple triangles instead of single triangle per face. Looks like cgal can't handle that but the rest of the system can. The STL file it exported was correct.. On 24 December 2015 at 07:45, Mekko <serve@perdix.org> wrote: LOL. Actually, I'm not the potato chip guy - I'm just trying to cut a sphere in half with an hyperbola and getting a potato chip instead. Hopefully the true Potato Chip Guy is reading this thread though! -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
P
Parkinbot
Thu, Dec 24, 2015 11:26 AM

Argh ... sorry again. The problem looked so similar. That made me think you
could be the same guy using different names. Maybe you are visiting the same
class? ;-)

By the way, you get both solutions by altering just one number!

// upper = point_function(range, .1);  // upper face
upper = point_function(range, 2);  // upper face

  • Rudolf

--
View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15317.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Argh ... sorry again. The problem looked so similar. That made me think you could be the same guy using different names. Maybe you are visiting the same class? ;-) By the way, you get both solutions by altering just one number! // upper = point_function(range, .1); // upper face upper = point_function(range, 2); // upper face - Rudolf -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15317.html Sent from the OpenSCAD mailing list archive at Nabble.com.
KS
Kenneth Sloan
Thu, Dec 24, 2015 12:57 PM

Looks nice.  So…I tried to copy it to play with it (and understand it).

I get:

ERROR: Parser error in line 38: syntax error
ERROR: Conmpilation failed!

Presumably, that’s because I’m behind on my updates.
What version do I need, please?

--
Kenneth Sloan
KennethRSloan@gmail.com mailto:KennethRSloan@gmail.com
Vision is the art of seeing what is invisible to others.

On Dec 24, 2015, at 04:01 , nop head nop.head@gmail.com wrote:

Here is a version that finally works.

<hyperbola.png>

xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.05;
zmin = min(xmin *ymax, xmax * ymin);

xpoints = floor((xmax - xmin) / step) + 1;
ypoints = floor((ymax - ymin) / step) + 1;
function index(x,y) = x * ypoints + y + 2;
function x(i) = xmin + i * step;
function y(i) = ymin + i * step;

points = concat([[xmin, ymin, zmin]],
[[xmax, ymax, zmin]],
[for(i = [0 : xpoints - 1]) for(j = [0 : ypoints - 1]) [x(i), y(j), x(i) * y(j)]]);

function flatten(l) = [for(a = l) for (b = a) b];

base = concat(
[[1, 0, index(xpoints - 1, 0)]],
[[0, 1, index(0, ypoints - 1)]],
[for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1, 0)]],
[for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0, j)]],
[for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), index(i, ypoints - 1)]],
[for(j = [0 : ypoints - 2]) [1, index(xpoints - 1, j), index(xpoints - 1, j + 1)]]
);

faces = flatten([for(i = [0 : xpoints - 2]) for(j = [0 : ypoints - 2])
[[index(i,j), index(i, j + 1), index(i + 1, j + 1)],
[index(i + 1, j + 1), index(i + 1, j ), index(i, j)]]
]);

difference() {
sphere(r= 0.5, $fn=80);
polyhedron(points, concat(base, faces), convexity = 2);
}

My stupid mistake was flattening the base list when it didn't need to be. The result was some faces with multiple triangles instead of single triangle per face. Looks like cgal can't handle that but the rest of the system can. The STL file it exported was correct..

On 24 December 2015 at 07:45, Mekko <serve@perdix.org mailto:serve@perdix.org> wrote:
LOL. Actually, I'm not the potato chip guy - I'm just trying to cut a sphere
in half with an hyperbola and getting a potato chip instead.

Hopefully the true Potato Chip Guy is reading this thread though!

--
View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org mailto:Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Looks nice. So…I tried to copy it to play with it (and understand it). I get: ERROR: Parser error in line 38: syntax error ERROR: Conmpilation failed! Presumably, that’s because I’m behind on my updates. What version do I need, please? -- Kenneth Sloan KennethRSloan@gmail.com <mailto:KennethRSloan@gmail.com> Vision is the art of seeing what is invisible to others. > On Dec 24, 2015, at 04:01 , nop head <nop.head@gmail.com> wrote: > > Here is a version that finally works. > > <hyperbola.png> > ​ > xmin = -1; > xmax = 1; > ymin = -1; > ymax = 1; > step = 0.05; > zmin = min(xmin *ymax, xmax * ymin); > > xpoints = floor((xmax - xmin) / step) + 1; > ypoints = floor((ymax - ymin) / step) + 1; > function index(x,y) = x * ypoints + y + 2; > function x(i) = xmin + i * step; > function y(i) = ymin + i * step; > > points = concat([[xmin, ymin, zmin]], > [[xmax, ymax, zmin]], > [for(i = [0 : xpoints - 1]) for(j = [0 : ypoints - 1]) [x(i), y(j), x(i) * y(j)]]); > > function flatten(l) = [for(a = l) for (b = a) b]; > > base = concat( > [[1, 0, index(xpoints - 1, 0)]], > [[0, 1, index(0, ypoints - 1)]], > [for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1, 0)]], > [for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0, j)]], > [for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), index(i, ypoints - 1)]], > [for(j = [0 : ypoints - 2]) [1, index(xpoints - 1, j), index(xpoints - 1, j + 1)]] > ); > > faces = flatten([for(i = [0 : xpoints - 2]) for(j = [0 : ypoints - 2]) > [[index(i,j), index(i, j + 1), index(i + 1, j + 1)], > [index(i + 1, j + 1), index(i + 1, j ), index(i, j)]] > ]); > > difference() { > sphere(r= 0.5, $fn=80); > polyhedron(points, concat(base, faces), convexity = 2); > } > ​ > > My stupid mistake was flattening the base list when it didn't need to be. The result was some faces with multiple triangles instead of single triangle per face. Looks like cgal can't handle that but the rest of the system can. The STL file it exported was correct.. > > On 24 December 2015 at 07:45, Mekko <serve@perdix.org <mailto:serve@perdix.org>> wrote: > LOL. Actually, I'm not the potato chip guy - I'm just trying to cut a sphere > in half with an hyperbola and getting a potato chip instead. > > Hopefully the true Potato Chip Guy is reading this thread though! > > > > -- > View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html <http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15313.html> > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org