discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

intersecting with an hyperbola

M
Mekko
Wed, Dec 23, 2015 3:44 PM

I need advice on how to model an hyperbola (i.e., z=xy). There's no primitive
like sphere() or cylinder() so I'm wondering what would be the best way to
do it.

In case it matters, my goal is to intersect it with a sphere to cut the
sphere in half.

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

I need advice on how to model an hyperbola (i.e., z=xy). There's no primitive like sphere() or cylinder() so I'm wondering what would be the best way to do it. In case it matters, my goal is to intersect it with a sphere to cut the sphere in half. -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280.html Sent from the OpenSCAD mailing list archive at Nabble.com.
PF
Peter Falke
Wed, Dec 23, 2015 4:16 PM

This depends somewhat on what kind of resolution you need.
You can stitch together a polyhedron from scratch.
Or you use the easy to understand, but slow chain-hull method.

Here is an example for a one dimensional case: z=x*x.
Generalize it to two dimensions and your good to go.
Just limit the $fn of the spheres to small numbers.

for (i=[-10:10-1]){
hull(){
s(i);
s(i+1);
t(i);
t(i+1);
}
}

module s(i){
translate([i,0,0.1ii])sphere(r=1,$fn=8);

}module t(i){
translate([i,0,0])sphere(r=1,$fn=8);
}

2015-12-23 16:44 GMT+01:00 Mekko serve@perdix.org:

I need advice on how to model an hyperbola (i.e., z=xy). There's no
primitive
like sphere() or cylinder() so I'm wondering what would be the best way to
do it.

In case it matters, my goal is to intersect it with a sphere to cut the
sphere in half.

--
View this message in context:
http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280.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

This depends somewhat on what kind of resolution you need. You can stitch together a polyhedron from scratch. Or you use the easy to understand, but slow chain-hull method. Here is an example for a one dimensional case: z=x*x. Generalize it to two dimensions and your good to go. Just limit the $fn of the spheres to small numbers. ​ for (i=[-10:10-1]){ hull(){ s(i); s(i+1); t(i); t(i+1); } } module s(i){ translate([i,0,0.1*i*i])sphere(r=1,$fn=8); }module t(i){ translate([i,0,0])sphere(r=1,$fn=8); } 2015-12-23 16:44 GMT+01:00 Mekko <serve@perdix.org>: > I need advice on how to model an hyperbola (i.e., z=xy). There's no > primitive > like sphere() or cylinder() so I'm wondering what would be the best way to > do it. > > In case it matters, my goal is to intersect it with a sphere to cut the > sphere in half. > > > > > -- > View this message in context: > http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280.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 >
PF
Peter Falke
Wed, Dec 23, 2015 4:20 PM

Or have a look at thingiverse.
I googled: thingiverse openscad function f(x)
and found this:

http://www.thingiverse.com/thing:24897

by dnewman http://www.thingiverse.com/dnewman

2015-12-23 17:16 GMT+01:00 Peter Falke stempeldergeschichte@googlemail.com
:

This depends somewhat on what kind of resolution you need.
You can stitch together a polyhedron from scratch.
Or you use the easy to understand, but slow chain-hull method.

Here is an example for a one dimensional case: z=x*x.
Generalize it to two dimensions and your good to go.
Just limit the $fn of the spheres to small numbers.

for (i=[-10:10-1]){
hull(){
s(i);
s(i+1);
t(i);
t(i+1);
}
}

module s(i){
translate([i,0,0.1ii])sphere(r=1,$fn=8);

}module t(i){
translate([i,0,0])sphere(r=1,$fn=8);
}

2015-12-23 16:44 GMT+01:00 Mekko serve@perdix.org:

I need advice on how to model an hyperbola (i.e., z=xy). There's no
primitive
like sphere() or cylinder() so I'm wondering what would be the best way to
do it.

In case it matters, my goal is to intersect it with a sphere to cut the
sphere in half.

--
View this message in context:
http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280.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

Or have a look at thingiverse. I googled: thingiverse openscad function f(x) and found this: http://www.thingiverse.com/thing:24897 by dnewman <http://www.thingiverse.com/dnewman> 2015-12-23 17:16 GMT+01:00 Peter Falke <stempeldergeschichte@googlemail.com> : > This depends somewhat on what kind of resolution you need. > You can stitch together a polyhedron from scratch. > Or you use the easy to understand, but slow chain-hull method. > > Here is an example for a one dimensional case: z=x*x. > Generalize it to two dimensions and your good to go. > Just limit the $fn of the spheres to small numbers. > > > ​ > > for (i=[-10:10-1]){ > hull(){ > s(i); > s(i+1); > t(i); > t(i+1); > } > } > > > module s(i){ > translate([i,0,0.1*i*i])sphere(r=1,$fn=8); > > }module t(i){ > translate([i,0,0])sphere(r=1,$fn=8); > } > > > > 2015-12-23 16:44 GMT+01:00 Mekko <serve@perdix.org>: > >> I need advice on how to model an hyperbola (i.e., z=xy). There's no >> primitive >> like sphere() or cylinder() so I'm wondering what would be the best way to >> do it. >> >> In case it matters, my goal is to intersect it with a sphere to cut the >> sphere in half. >> >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280.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 >> > >
TP
Torsten Paul
Wed, Dec 23, 2015 4:58 PM

On 12/23/2015 05:20 PM, Peter Falke wrote:

Or have a look at thingiverse.
I googled: thingiverse openscad function f(x)
and found this:

http://www.thingiverse.com/thing:24897

by dnewman http://www.thingiverse.com/dnewman

This seems to be written before the list comprehension features
were available so it uses a union of lots of small polyhedrons
which will make it quite slow at higher resolutions.

The 3d-function.scad might be able to generate a similar 3d-plot
too as single polyhedron:

https://github.com/openscad/list-comprehension-demos

ciao,
Torsten.

On 12/23/2015 05:20 PM, Peter Falke wrote: > Or have a look at thingiverse. > I googled: thingiverse openscad function f(x) > and found this: > > http://www.thingiverse.com/thing:24897 > > by dnewman <http://www.thingiverse.com/dnewman> > > This seems to be written before the list comprehension features were available so it uses a union of lots of small polyhedrons which will make it quite slow at higher resolutions. The 3d-function.scad might be able to generate a similar 3d-plot too as single polyhedron: https://github.com/openscad/list-comprehension-demos ciao, Torsten.
P
Parkinbot
Wed, Dec 23, 2015 5:03 PM

try something like this:

$fn=100;

difference()
{
sphere(.99);
rotate_extrude()
polygon(points = concat([[0,1]], hyperbola(1, .02)));
}

function hyperbola(X, step) = [for(i=[0:step:X])[i, i*i]];

  • Rudolf

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

try something like this: $fn=100; difference() { sphere(.99); rotate_extrude() polygon(points = concat([[0,1]], hyperbola(1, .02))); } function hyperbola(X, step) = [for(i=[0:step:X])[i, i*i]]; - Rudolf -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15284.html Sent from the OpenSCAD mailing list archive at Nabble.com.
TP
Torsten Paul
Wed, Dec 23, 2015 5:11 PM

On 12/23/2015 06:03 PM, Parkinbot wrote:

try something like this:

Ahh, very good point. Using rotate_extrude is much better.

ciao,
Torsten.

On 12/23/2015 06:03 PM, Parkinbot wrote: > try something like this: > Ahh, very good point. Using rotate_extrude is much better. ciao, Torsten.
NH
nop head
Wed, Dec 23, 2015 5:15 PM

It isn't the right shape though, unless I misunderstand the original
question. A rotated hyperbola is not the same as a 3D hyperbola z = x * y.

On 23 December 2015 at 17:11, Torsten Paul Torsten.Paul@gmx.de wrote:

On 12/23/2015 06:03 PM, Parkinbot wrote:

try something like this:

Ahh, very good point. Using rotate_extrude is much better.

ciao,
Torsten.


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

It isn't the right shape though, unless I misunderstand the original question. A rotated hyperbola is not the same as a 3D hyperbola z = x * y. On 23 December 2015 at 17:11, Torsten Paul <Torsten.Paul@gmx.de> wrote: > On 12/23/2015 06:03 PM, Parkinbot wrote: > > try something like this: > > > Ahh, very good point. Using rotate_extrude is much better. > > ciao, > Torsten. > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Wed, Dec 23, 2015 5:32 PM

It looks like this: -

Here is the code I used to make it:
xmin = 0;
xmax = 1;
ymin = 0;
ymax = 1;
step = 0.05;

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

points = concat([[x(xpoints - 1), y(ypoints - 1), 0]],
[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 = [[0, 1, index(xpoints -1, 0)],
[1, 0, index(0, ypoints -1)],
[0, index(xpoints - 1, ypoints - 1), index(0, ypoints - 1)],
[0, index(xpoints - 1, 0), index(xpoints - 1, ypoints - 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)]]
]);

polyhedron(points, concat(base, faces));

On 23 December 2015 at 17:15, nop head nop.head@gmail.com wrote:

It isn't the right shape though, unless I misunderstand the original
question. A rotated hyperbola is not the same as a 3D hyperbola z = x * y.

On 23 December 2015 at 17:11, Torsten Paul Torsten.Paul@gmx.de wrote:

On 12/23/2015 06:03 PM, Parkinbot wrote:

try something like this:

Ahh, very good point. Using rotate_extrude is much better.

ciao,
Torsten.


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

It looks like this: - Here is the code I used to make it: xmin = 0; xmax = 1; ymin = 0; ymax = 1; step = 0.05; xpoints = floor((xmax - xmin) / step) + 1; ypoints = floor((ymax - ymin) / step) + 1; function index(x,y) = x * ypoints + y + 1; function x(i) = xmin + i * step; function y(i) = ymin + i * step; points = concat([[x(xpoints - 1), y(ypoints - 1), 0]], [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 = [[0, 1, index(xpoints -1, 0)], [1, 0, index(0, ypoints -1)], [0, index(xpoints - 1, ypoints - 1), index(0, ypoints - 1)], [0, index(xpoints - 1, 0), index(xpoints - 1, ypoints - 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)]] ]); polyhedron(points, concat(base, faces)); ​ On 23 December 2015 at 17:15, nop head <nop.head@gmail.com> wrote: > It isn't the right shape though, unless I misunderstand the original > question. A rotated hyperbola is not the same as a 3D hyperbola z = x * y. > > On 23 December 2015 at 17:11, Torsten Paul <Torsten.Paul@gmx.de> wrote: > >> On 12/23/2015 06:03 PM, Parkinbot wrote: >> > try something like this: >> > >> Ahh, very good point. Using rotate_extrude is much better. >> >> ciao, >> Torsten. >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > >
HL
Hans L
Wed, Dec 23, 2015 5:54 PM

Check out the list comprehension demo repo
https://github.com/openscad/list-comprehension-demos/

Specifically the 3d functions demo
On Dec 23, 2015 10:21 AM, "Peter Falke" stempeldergeschichte@googlemail.com
wrote:

Or have a look at thingiverse.
I googled: thingiverse openscad function f(x)
and found this:

http://www.thingiverse.com/thing:24897

by dnewman http://www.thingiverse.com/dnewman

2015-12-23 17:16 GMT+01:00 Peter Falke <
stempeldergeschichte@googlemail.com>:

This depends somewhat on what kind of resolution you need.
You can stitch together a polyhedron from scratch.
Or you use the easy to understand, but slow chain-hull method.

Here is an example for a one dimensional case: z=x*x.
Generalize it to two dimensions and your good to go.
Just limit the $fn of the spheres to small numbers.

for (i=[-10:10-1]){
hull(){
s(i);
s(i+1);
t(i);
t(i+1);
}
}

module s(i){
translate([i,0,0.1ii])sphere(r=1,$fn=8);

}module t(i){
translate([i,0,0])sphere(r=1,$fn=8);
}

2015-12-23 16:44 GMT+01:00 Mekko serve@perdix.org:

I need advice on how to model an hyperbola (i.e., z=xy). There's no
primitive
like sphere() or cylinder() so I'm wondering what would be the best way
to
do it.

In case it matters, my goal is to intersect it with a sphere to cut the
sphere in half.

--
View this message in context:
http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280.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

Check out the list comprehension demo repo https://github.com/openscad/list-comprehension-demos/ Specifically the 3d functions demo On Dec 23, 2015 10:21 AM, "Peter Falke" <stempeldergeschichte@googlemail.com> wrote: > Or have a look at thingiverse. > I googled: thingiverse openscad function f(x) > and found this: > > http://www.thingiverse.com/thing:24897 > > by dnewman <http://www.thingiverse.com/dnewman> > > 2015-12-23 17:16 GMT+01:00 Peter Falke < > stempeldergeschichte@googlemail.com>: > >> This depends somewhat on what kind of resolution you need. >> You can stitch together a polyhedron from scratch. >> Or you use the easy to understand, but slow chain-hull method. >> >> Here is an example for a one dimensional case: z=x*x. >> Generalize it to two dimensions and your good to go. >> Just limit the $fn of the spheres to small numbers. >> >> >> ​ >> >> for (i=[-10:10-1]){ >> hull(){ >> s(i); >> s(i+1); >> t(i); >> t(i+1); >> } >> } >> >> >> module s(i){ >> translate([i,0,0.1*i*i])sphere(r=1,$fn=8); >> >> }module t(i){ >> translate([i,0,0])sphere(r=1,$fn=8); >> } >> >> >> >> 2015-12-23 16:44 GMT+01:00 Mekko <serve@perdix.org>: >> >>> I need advice on how to model an hyperbola (i.e., z=xy). There's no >>> primitive >>> like sphere() or cylinder() so I'm wondering what would be the best way >>> to >>> do it. >>> >>> In case it matters, my goal is to intersect it with a sphere to cut the >>> sphere in half. >>> >>> >>> >>> >>> -- >>> View this message in context: >>> http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280.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 >>> >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
M
Mekko
Wed, Dec 23, 2015 6:15 PM

Exactly right, nophead: a rotated 2D hyperbola != a 3D hyperbola.

Thanks for the code! I need the actual saddle area and when I put in -1 for
the minimum x and y values (instead of 0), it kind of "self-intersects"
through the origin as it ties the faces to [1,1,0] and [-1,-1,1].

I suppose I could whack "points = concat([[x(xpoints - 1), y(ypoints - 1),
0]], ..." and change the 0 to like -5 or something but it worries me that I
don't understand the code well enough to cover this case properly.  Can you
show me the correct way?

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

Exactly right, nophead: a rotated 2D hyperbola != a 3D hyperbola. Thanks for the code! I need the actual saddle area and when I put in -1 for the minimum x and y values (instead of 0), it kind of "self-intersects" through the origin as it ties the faces to [1,1,0] and [-1,-1,1]. I suppose I could whack "points = concat([[x(xpoints - 1), y(ypoints - 1), 0]], ..." and change the 0 to like -5 or something but it worries me that I don't understand the code well enough to cover this case properly. Can you show me the correct way? -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15289.html Sent from the OpenSCAD mailing list archive at Nabble.com.