discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

intersecting with an hyperbola

NH
nop head
Wed, Dec 23, 2015 6:32 PM

That is actually simpler as it can be closed by two triangles.

​xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.05;

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

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

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 18:15, Mekko serve@perdix.org wrote:

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.


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

That is actually simpler as it can be closed by two triangles. ​xmin = -1; xmax = 1; ymin = -1; ymax = 1; step = 0.05; xpoints = floor((xmax - xmin) / step) + 1; ypoints = floor((ymax - ymin) / step) + 1; function index(x,y) = x * ypoints + y; function x(i) = xmin + i * step; function y(i) = ymin + i * step; points = [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 = [ [index(0, 0), index(xpoints -1, 0), index(0, ypoints -1)], [index(xpoints -1, ypoints -1), index(0, ypoints -1), index(xpoints -1, 0)], ]; 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 18:15, Mekko <serve@perdix.org> wrote: > 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. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Wed, Dec 23, 2015 7:23 PM

Or maybe this shape is more useful.

​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 = [
[1, 0, index(xpoints -1, 0)],
[0, 1, index(0, ypoints -1)],
[0, index(0, 0), index(xpoints - 1,0)],
[0, index(0, ypoints -1), index(0, 0)],
[1, index(xpoints - 1, ypoints - 1), index(0, ypoints -1)],
[1, 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 18:32, nop head nop.head@gmail.com wrote:

That is actually simpler as it can be closed by two triangles.

​xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.05;

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

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

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 18:15, Mekko serve@perdix.org wrote:

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.


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

Or maybe this shape is more useful. ​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 = [ [1, 0, index(xpoints -1, 0)], [0, 1, index(0, ypoints -1)], [0, index(0, 0), index(xpoints - 1,0)], [0, index(0, ypoints -1), index(0, 0)], [1, index(xpoints - 1, ypoints - 1), index(0, ypoints -1)], [1, 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 18:32, nop head <nop.head@gmail.com> wrote: > That is actually simpler as it can be closed by two triangles. > > > ​xmin = -1; > xmax = 1; > ymin = -1; > ymax = 1; > step = 0.05; > > xpoints = floor((xmax - xmin) / step) + 1; > ypoints = floor((ymax - ymin) / step) + 1; > function index(x,y) = x * ypoints + y; > function x(i) = xmin + i * step; > function y(i) = ymin + i * step; > > points = [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 = [ > [index(0, 0), index(xpoints -1, 0), index(0, ypoints -1)], > [index(xpoints -1, ypoints -1), index(0, ypoints -1), > index(xpoints -1, 0)], > ]; > > 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 18:15, Mekko <serve@perdix.org> wrote: > >> 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. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > >
M
Mekko
Wed, Dec 23, 2015 7:24 PM

That's exactly what I needed. Thank you!

Cutting a sphere with it throws an exception for some reason. This code:

difference() {
sphere(r=.5, $fn=20);
polyhedron(points, concat(base, faces));
}

generates this error:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion
violation! Expr: e->incident_sface() != SFace_const_handle() File:
/data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h
Line: 326

Suggestions?

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

That's exactly what I needed. Thank you! Cutting a sphere with it throws an exception for some reason. This code: difference() { sphere(r=.5, $fn=20); polyhedron(points, concat(base, faces)); } generates this error: ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326 Suggestions? -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15291.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Wed, Dec 23, 2015 7:37 PM

It is because I closed the faces with single triangles creating lots of t
junctions where the small triangles meet. It needs to be closed with
triangle fans, my mistake.

On 23 December 2015 at 19:24, Mekko serve@perdix.org wrote:

That's exactly what I needed. Thank you!

Cutting a sphere with it throws an exception for some reason. This code:

difference() {
sphere(r=.5, $fn=20);
polyhedron(points, concat(base, faces));
}

generates this error:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion
violation! Expr: e->incident_sface() != SFace_const_handle() File:

/data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h
Line: 326

Suggestions?

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

It is because I closed the faces with single triangles creating lots of t junctions where the small triangles meet. It needs to be closed with triangle fans, my mistake. On 23 December 2015 at 19:24, Mekko <serve@perdix.org> wrote: > That's exactly what I needed. Thank you! > > Cutting a sphere with it throws an exception for some reason. This code: > > difference() { > sphere(r=.5, $fn=20); > polyhedron(points, concat(base, faces)); > } > > generates this error: > > ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion > violation! Expr: e->incident_sface() != SFace_const_handle() File: > > /data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h > Line: 326 > > Suggestions? > > > > > > -- > View this message in context: > http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15291.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 >
NH
nop head
Wed, Dec 23, 2015 8:04 PM

Here is one that works: -
xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.1;
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 = [
[1, 0, index(xpoints -1, 0)],
[0, 1, index(0, ypoints -1)],
flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i +
1,0)]]),
flatten([for(j = [0 : ypoints - 2]) [0, index(0, j), index(0, j +
1)]]),
flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1),
index(i, ypoints - 1)]]),
flatten([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=.5, $fn=20);
polyhedron(points, concat(base, faces), convexity = 2);
}

On 23 December 2015 at 19:37, nop head nop.head@gmail.com wrote:

It is because I closed the faces with single triangles creating lots of t
junctions where the small triangles meet. It needs to be closed with
triangle fans, my mistake.

On 23 December 2015 at 19:24, Mekko serve@perdix.org wrote:

That's exactly what I needed. Thank you!

Cutting a sphere with it throws an exception for some reason. This code:

difference() {
sphere(r=.5, $fn=20);
polyhedron(points, concat(base, faces));
}

generates this error:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion
violation! Expr: e->incident_sface() != SFace_const_handle() File:

/data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h
Line: 326

Suggestions?

--
View this message in context:
http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15291.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 one that works: - xmin = -1; xmax = 1; ymin = -1; ymax = 1; step = 0.1; 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 = [ [1, 0, index(xpoints -1, 0)], [0, 1, index(0, ypoints -1)], flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1,0)]]), flatten([for(j = [0 : ypoints - 2]) [0, index(0, j), index(0, j + 1)]]), flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), index(i, ypoints - 1)]]), flatten([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=.5, $fn=20); polyhedron(points, concat(base, faces), convexity = 2); } On 23 December 2015 at 19:37, nop head <nop.head@gmail.com> wrote: > It is because I closed the faces with single triangles creating lots of t > junctions where the small triangles meet. It needs to be closed with > triangle fans, my mistake. > > On 23 December 2015 at 19:24, Mekko <serve@perdix.org> wrote: > >> That's exactly what I needed. Thank you! >> >> Cutting a sphere with it throws an exception for some reason. This code: >> >> difference() { >> sphere(r=.5, $fn=20); >> polyhedron(points, concat(base, faces)); >> } >> >> generates this error: >> >> ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion >> violation! Expr: e->incident_sface() != SFace_const_handle() File: >> >> /data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h >> Line: 326 >> >> Suggestions? >> >> >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15291.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 >> > >
NH
nop head
Wed, Dec 23, 2015 8:24 PM

Actually it still doesn't work. I found one bug but I am stuck now. The
error as gone away but it still doesn't render:

xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.1;
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 = [
[1, 0, index(xpoints -1, 0)],
[0, 1, index(0, ypoints -1)],
flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1,
0)]]),
flatten([for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0,
j)]]),
flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1),
index(i, ypoints - 1)]]),
flatten([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=.5, $fn=20);
polyhedron(points, concat(base, faces), convexity = 2);
}

On 23 December 2015 at 20:04, nop head nop.head@gmail.com wrote:

Here is one that works: -
xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.1;
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 = [
[1, 0, index(xpoints -1, 0)],
[0, 1, index(0, ypoints -1)],
flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i +
1,0)]]),
flatten([for(j = [0 : ypoints - 2]) [0, index(0, j), index(0, j +
1)]]),
flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1),
index(i, ypoints - 1)]]),
flatten([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=.5, $fn=20);
polyhedron(points, concat(base, faces), convexity = 2);
}

On 23 December 2015 at 19:37, nop head nop.head@gmail.com wrote:

It is because I closed the faces with single triangles creating lots of t
junctions where the small triangles meet. It needs to be closed with
triangle fans, my mistake.

On 23 December 2015 at 19:24, Mekko serve@perdix.org wrote:

That's exactly what I needed. Thank you!

Cutting a sphere with it throws an exception for some reason. This code:

difference() {
sphere(r=.5, $fn=20);
polyhedron(points, concat(base, faces));
}

generates this error:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion
violation! Expr: e->incident_sface() != SFace_const_handle() File:

/data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h
Line: 326

Suggestions?

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

Actually it still doesn't work. I found one bug but I am stuck now. The error as gone away but it still doesn't render: xmin = -1; xmax = 1; ymin = -1; ymax = 1; step = 0.1; 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 = [ [1, 0, index(xpoints -1, 0)], [0, 1, index(0, ypoints -1)], flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1, 0)]]), flatten([for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0, j)]]), flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), index(i, ypoints - 1)]]), flatten([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=.5, $fn=20); polyhedron(points, concat(base, faces), convexity = 2); } On 23 December 2015 at 20:04, nop head <nop.head@gmail.com> wrote: > Here is one that works: - > xmin = -1; > xmax = 1; > ymin = -1; > ymax = 1; > step = 0.1; > 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 = [ > [1, 0, index(xpoints -1, 0)], > [0, 1, index(0, ypoints -1)], > flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + > 1,0)]]), > flatten([for(j = [0 : ypoints - 2]) [0, index(0, j), index(0, j + > 1)]]), > flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), > index(i, ypoints - 1)]]), > flatten([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=.5, $fn=20); > polyhedron(points, concat(base, faces), convexity = 2); > } > > On 23 December 2015 at 19:37, nop head <nop.head@gmail.com> wrote: > >> It is because I closed the faces with single triangles creating lots of t >> junctions where the small triangles meet. It needs to be closed with >> triangle fans, my mistake. >> >> On 23 December 2015 at 19:24, Mekko <serve@perdix.org> wrote: >> >>> That's exactly what I needed. Thank you! >>> >>> Cutting a sphere with it throws an exception for some reason. This code: >>> >>> difference() { >>> sphere(r=.5, $fn=20); >>> polyhedron(points, concat(base, faces)); >>> } >>> >>> generates this error: >>> >>> ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion >>> violation! Expr: e->incident_sface() != SFace_const_handle() File: >>> >>> /data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h >>> Line: 326 >>> >>> Suggestions? >>> >>> >>> >>> >>> >>> -- >>> View this message in context: >>> http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15291.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 >>> >> >> >
NH
nop head
Wed, Dec 23, 2015 8:40 PM

In fact the error is still there when I flush the caches.

On 23 December 2015 at 20:24, nop head nop.head@gmail.com wrote:

Actually it still doesn't work. I found one bug but I am stuck now. The
error as gone away but it still doesn't render:

xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.1;
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 = [
[1, 0, index(xpoints -1, 0)],
[0, 1, index(0, ypoints -1)],
flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1,
0)]]),
flatten([for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0,
j)]]),
flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1),
index(i, ypoints - 1)]]),
flatten([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=.5, $fn=20);
polyhedron(points, concat(base, faces), convexity = 2);
}

On 23 December 2015 at 20:04, nop head nop.head@gmail.com wrote:

Here is one that works: -
xmin = -1;
xmax = 1;
ymin = -1;
ymax = 1;
step = 0.1;
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 = [
[1, 0, index(xpoints -1, 0)],
[0, 1, index(0, ypoints -1)],
flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i +
1,0)]]),
flatten([for(j = [0 : ypoints - 2]) [0, index(0, j), index(0, j +
1)]]),
flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints -
1), index(i, ypoints - 1)]]),
flatten([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=.5, $fn=20);
polyhedron(points, concat(base, faces), convexity = 2);
}

On 23 December 2015 at 19:37, nop head nop.head@gmail.com wrote:

It is because I closed the faces with single triangles creating lots of
t junctions where the small triangles meet. It needs to be closed with
triangle fans, my mistake.

On 23 December 2015 at 19:24, Mekko serve@perdix.org wrote:

That's exactly what I needed. Thank you!

Cutting a sphere with it throws an exception for some reason. This code:

difference() {
sphere(r=.5, $fn=20);
polyhedron(points, concat(base, faces));
}

generates this error:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion
violation! Expr: e->incident_sface() != SFace_const_handle() File:

/data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h
Line: 326

Suggestions?

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

In fact the error is still there when I flush the caches. On 23 December 2015 at 20:24, nop head <nop.head@gmail.com> wrote: > Actually it still doesn't work. I found one bug but I am stuck now. The > error as gone away but it still doesn't render: > > xmin = -1; > xmax = 1; > ymin = -1; > ymax = 1; > step = 0.1; > 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 = [ > [1, 0, index(xpoints -1, 0)], > [0, 1, index(0, ypoints -1)], > flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + 1, > 0)]]), > flatten([for(j = [0 : ypoints - 2]) [0, index(0, j + 1), index(0, > j)]]), > flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - 1), > index(i, ypoints - 1)]]), > flatten([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=.5, $fn=20); > polyhedron(points, concat(base, faces), convexity = 2); > } > > On 23 December 2015 at 20:04, nop head <nop.head@gmail.com> wrote: > >> Here is one that works: - >> xmin = -1; >> xmax = 1; >> ymin = -1; >> ymax = 1; >> step = 0.1; >> 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 = [ >> [1, 0, index(xpoints -1, 0)], >> [0, 1, index(0, ypoints -1)], >> flatten([for(i = [0 : xpoints - 2]) [0, index(i, 0), index(i + >> 1,0)]]), >> flatten([for(j = [0 : ypoints - 2]) [0, index(0, j), index(0, j + >> 1)]]), >> flatten([for(i = [0 : xpoints - 2]) [1, index(i + 1, ypoints - >> 1), index(i, ypoints - 1)]]), >> flatten([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=.5, $fn=20); >> polyhedron(points, concat(base, faces), convexity = 2); >> } >> >> On 23 December 2015 at 19:37, nop head <nop.head@gmail.com> wrote: >> >>> It is because I closed the faces with single triangles creating lots of >>> t junctions where the small triangles meet. It needs to be closed with >>> triangle fans, my mistake. >>> >>> On 23 December 2015 at 19:24, Mekko <serve@perdix.org> wrote: >>> >>>> That's exactly what I needed. Thank you! >>>> >>>> Cutting a sphere with it throws an exception for some reason. This code: >>>> >>>> difference() { >>>> sphere(r=.5, $fn=20); >>>> polyhedron(points, concat(base, faces)); >>>> } >>>> >>>> generates this error: >>>> >>>> ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion >>>> violation! Expr: e->incident_sface() != SFace_const_handle() File: >>>> >>>> /data/OpenSCAD/libraries-mingw32-master/mxe/usr/i686-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h >>>> Line: 326 >>>> >>>> Suggestions? >>>> >>>> >>>> >>>> >>>> >>>> -- >>>> View this message in context: >>>> http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15291.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
Wed, Dec 23, 2015 11:01 PM

This stuff is way over my head but FWIW, this code:

intersection() {
polyhedron(points, concat(base, faces), convexity = 2);
sphere(r=.5, $fn=80);
}

generates a preview of a zero-thickness contour (that looks like a potato
chip). That is, the intersection() shows only where the surface of the
polyhedron intersects with the volume of the sphere and excludes all the
volume that the two objects share.

Maybe that is useful to know.

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

This stuff is way over my head but FWIW, this code: intersection() { polyhedron(points, concat(base, faces), convexity = 2); sphere(r=.5, $fn=80); } generates a preview of a zero-thickness contour (that looks like a potato chip). That is, the intersection() shows only where the *surface* of the polyhedron intersects with the volume of the sphere and excludes all the volume that the two objects share. Maybe that is useful to know. -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15300.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Wed, Dec 23, 2015 11:39 PM

For some reason GCAL doesn't like my polyhedron but I can't see why. I can
export it to an STL and it looks fine in netfabb as well.

On 23 December 2015 at 23:01, Mekko serve@perdix.org wrote:

This stuff is way over my head but FWIW, this code:

intersection() {
polyhedron(points, concat(base, faces), convexity = 2);
sphere(r=.5, $fn=80);
}

generates a preview of a zero-thickness contour (that looks like a potato
chip). That is, the intersection() shows only where the surface of the
polyhedron intersects with the volume of the sphere and excludes all the
volume that the two objects share.

Maybe that is useful to know.

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

For some reason GCAL doesn't like my polyhedron but I can't see why. I can export it to an STL and it looks fine in netfabb as well. On 23 December 2015 at 23:01, Mekko <serve@perdix.org> wrote: > This stuff is way over my head but FWIW, this code: > > intersection() { > polyhedron(points, concat(base, faces), convexity = 2); > sphere(r=.5, $fn=80); > } > > generates a preview of a zero-thickness contour (that looks like a potato > chip). That is, the intersection() shows only where the *surface* of the > polyhedron intersects with the volume of the sphere and excludes all the > volume that the two objects share. > > Maybe that is useful to know. > > > > > -- > View this message in context: > http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15300.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 >
N
Neon22
Thu, Dec 24, 2015 3:40 AM
  1. If I change for(i = [0 : xpoints - 1])
    to for(i = [0 : xpoints - 0])
    I see no visual change.

  2. Also when I F6 the object I get a result but its not using the color
    scheme I've chosen.
    I think this means there is something wrong with the model.

  3. If I reverse the difference:
    difference() {
    polyhedron(points, concat(base, faces), convexity = 2);
    sphere(r=.5, $fn=45);
    }
    I get a CGAL error - coincident face.
    ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion
    violation! Expr: e->incident_sface() != SFace_const_handle() File:
    /data/OpenSCAD/libraries-mingw64-master/mxe-w64/usr/x86_64-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h
    Line: 326

Looks like one of the indices is off in base=... ??maybe??
still looking

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

1. If I change for(i = [0 : xpoints - 1]) to for(i = [0 : xpoints - 0]) I see no visual change. 2. Also when I F6 the object I get a result but its not using the color scheme I've chosen. I think this means there is something wrong with the model. 3. If I reverse the difference: difference() { polyhedron(points, concat(base, faces), convexity = 2); sphere(r=.5, $fn=45); } I get a CGAL error - coincident face. ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /data/OpenSCAD/libraries-mingw64-master/mxe-w64/usr/x86_64-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326 Looks like one of the indices is off in base=... ??maybe?? still looking -- View this message in context: http://forum.openscad.org/intersecting-with-an-hyperbola-tp15280p15305.html Sent from the OpenSCAD mailing list archive at Nabble.com.