discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

request: surface() from 2D array

W
whosawhatsis
Tue, Aug 18, 2015 8:38 AM

Would it be difficult to modify the surface module to be able to build from an 2D array within OpenSCAD rather than loading an external file? I've found ways to get the same result, but they are MUCH slower. What I'd like to do is, for example, produce an array from a mathematical function, then feed it to surface() to visualize the function. I know I could generate the function externally and create a file (or probably even pipe it to OpenSCAD on the command line), but I'd like to be able to do everything from within the OpenSCAD file.

Would it be difficult to modify the surface module to be able to build from an 2D array within OpenSCAD rather than loading an external file? I've found ways to get the same result, but they are MUCH slower. What I'd like to do is, for example, produce an array from a mathematical function, then feed it to surface() to visualize the function. I know I could generate the function externally and create a file (or probably even pipe it to OpenSCAD on the command line), but I'd like to be able to do everything from within the OpenSCAD file.
TP
Torsten Paul
Tue, Aug 18, 2015 9:11 AM

On 08/18/2015 10:38 AM, whosawhatsis wrote:

Would it be difficult to modify the surface module to be able to
build from an 2D array within OpenSCAD rather than loading an
external file?

That's probably not too complicated, it's relatively easy to do in
user-space though, see

https://github.com/openscad/list-comprehension-demos/blob/master/3d-function.scad

for an example that shows a function z = f(x, y).

ciao,
Torsten.

On 08/18/2015 10:38 AM, whosawhatsis wrote: > Would it be difficult to modify the surface module to be able to > build from an 2D array within OpenSCAD rather than loading an > external file? > That's probably not too complicated, it's relatively easy to do in user-space though, see https://github.com/openscad/list-comprehension-demos/blob/master/3d-function.scad for an example that shows a function z = f(x, y). ciao, Torsten.
W
whosawhatsis
Tue, Aug 18, 2015 9:59 AM

I hadn't thought about using polyhedron to do it. I learned OpenSCAD back when polyhedron was utterly useless because recursion wasn't allowed and it was thus impossible to programmatically build arrays.

Trying the demo, it's exactly what I was trying to do. The solution I came up with using a lot of convex hull operations generates slightly cleaner results because it determines the best orientation to split each quad into triangles, but it's not nearly as fast as this.

Thanks.

It would still by nice to be able to use surface on a set of points generated this way, instead of using polyhedron, though.

On Tuesday, August 18, 2015 at 02:11, Torsten Paul wrote:

On 08/18/2015 10:38 AM, whosawhatsis wrote:

Would it be difficult to modify the surface module to be able to
build from an 2D array within OpenSCAD rather than loading an
external file?

That's probably not too complicated, it's relatively easy to do in
user-space though, see

https://github.com/openscad/list-comprehension-demos/blob/master/3d-function.scad

for an example that shows a function z = f(x, y).

ciao,
Torsten.


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

I hadn't thought about using polyhedron to do it. I learned OpenSCAD back when polyhedron was utterly useless because recursion wasn't allowed and it was thus impossible to programmatically build arrays. Trying the demo, it's exactly what I was trying to do. The solution I came up with using a lot of convex hull operations generates slightly cleaner results because it determines the best orientation to split each quad into triangles, but it's not nearly as fast as this. Thanks. It would still by nice to be able to use surface on a set of points generated this way, instead of using polyhedron, though. On Tuesday, August 18, 2015 at 02:11, Torsten Paul wrote: > On 08/18/2015 10:38 AM, whosawhatsis wrote: > > Would it be difficult to modify the surface module to be able to > > build from an 2D array within OpenSCAD rather than loading an > > external file? > > > > That's probably not too complicated, it's relatively easy to do in > user-space though, see > > https://github.com/openscad/list-comprehension-demos/blob/master/3d-function.scad > > for an example that shows a function z = f(x, y). > > ciao, > Torsten. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org (mailto:Discuss@lists.openscad.org) > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >