discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

surface without import?

AD
Ari Diacou
Thu, Jul 4, 2019 4:15 PM

I have a logo i want to use as a stamp. Is there any way I can use
surface() without having to specify a filename? I'd like to have it in my
library file and not have dependencies (since i call the file from
different computers on my network).

//For example:
array = [[barf],[hurk],[sick]];
surface(array);

Thanks,
--Ari MD

I have a logo i want to use as a stamp. Is there any way I can use surface() without having to specify a filename? I'd like to have it in my library file and not have dependencies (since i call the file from different computers on my network). //For example: array = [[barf],[hurk],[sick]]; surface(array); Thanks, --Ari MD
M
MichaelAtOz
Thu, Jul 4, 2019 11:43 PM

drxenocide wrote

can use surface() without having to specify a filename?

No.


Admin - email* me if you need anything, or if I've done something stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

Sent from: http://forum.openscad.org/

drxenocide wrote > can use surface() without having to specify a filename? No. ----- Admin - email* me if you need anything, or if I've done something stupid... * click on my MichaelAtOz label, there is a link to email me. Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Fri, Jul 5, 2019 1:58 AM

Interesting alternative. It cannot be performed by surface() but it can be
done in user space with polyhedron().

data = [ for(a=[0:10:360])
[ for(b=[0:10:360])
cos(a-b)+4*sin(a+b)+(a+b)/40 ]
];

surfaceData(data, center=true);
cube();

// operate like the builtin module surface() but
// from a matrix of floats instead of a text file
module surfaceData(M, center=false, convexity=10){
n = len(M);
m = len(M[0]);
miz  = min([for(Mi=M) min(Mi)]);
minz = miz<0? miz-1 : -1;
ctr  = center ? [-(m-1)/2, -(n-1)/2, 0]: [0,0,0];
points = [ // original data points
for(i=[0:n-1])for(j=[0:m-1]) [j, i, M[i][j]] +ctr,
[  0,  0, minz ] + ctr,
[ m-1,  0, minz ] + ctr,
[ m-1, n-1, minz ] + ctr,
[  0, n-1, minz ] + ctr,
// additional interpolated points
// the points bellow with undef coordinates are not used by
faces
for(i=[0:n-1])for(j=[0:m-1])
let( med = (M[i][j]+M[i+1][j]+M[i+1][j+1]+M[i][j+1])/4 )
[j+0.5, i+0.5, med] + ctr
];
faces = [ // faces connecting data points to interpolated ones
for(i=[0:n-2])
for(j=[im:im+m-2])
each [ [  j+1,    j, j+nm+4 ],
[    j,  j+m, j+n
m+4 ],
[  j+m, j+m+1, j+nm+4 ],
[ j+m+1,  j+1, j+n
m+4 ] ] ,
// lateral and bottom faces
[ for(i=[0:m-1])          i, nm+1,  nm ],
[ for(i=[m-1:-1:0]) -m+i+nm, nm+3, nm+2 ],
[ for(i=[n-1:-1:0])      i
m,  nm, nm+3 ],
[ for(i=[0:n-1])    im+m-1, nm+2, nm+1 ],
[n
m, nm+1, nm+2, n*m+3 ]
];
polyhedron(points, faces, convexity);
}

Em qui, 4 de jul de 2019 às 17:16, Ari Diacou ari.diacou@gmail.com
escreveu:

I have a logo i want to use as a stamp. Is there any way I can use
surface() without having to specify a filename? I'd like to have it in my
library file and not have dependencies (since i call the file from
different computers on my network).

//For example:
array = [[barf],[hurk],[sick]];
surface(array);

Thanks,
--Ari MD


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

Interesting alternative. It cannot be performed by surface() but it can be done in user space with polyhedron(). data = [ for(a=[0:10:360]) [ for(b=[0:10:360]) cos(a-b)+4*sin(a+b)+(a+b)/40 ] ]; surfaceData(data, center=true); cube(); // operate like the builtin module surface() but // from a matrix of floats instead of a text file module surfaceData(M, center=false, convexity=10){ n = len(M); m = len(M[0]); miz = min([for(Mi=M) min(Mi)]); minz = miz<0? miz-1 : -1; ctr = center ? [-(m-1)/2, -(n-1)/2, 0]: [0,0,0]; points = [ // original data points for(i=[0:n-1])for(j=[0:m-1]) [j, i, M[i][j]] +ctr, [ 0, 0, minz ] + ctr, [ m-1, 0, minz ] + ctr, [ m-1, n-1, minz ] + ctr, [ 0, n-1, minz ] + ctr, // additional interpolated points // the points bellow with undef coordinates are not used by faces for(i=[0:n-1])for(j=[0:m-1]) let( med = (M[i][j]+M[i+1][j]+M[i+1][j+1]+M[i][j+1])/4 ) [j+0.5, i+0.5, med] + ctr ]; faces = [ // faces connecting data points to interpolated ones for(i=[0:n-2]) for(j=[i*m:i*m+m-2]) each [ [ j+1, j, j+n*m+4 ], [ j, j+m, j+n*m+4 ], [ j+m, j+m+1, j+n*m+4 ], [ j+m+1, j+1, j+n*m+4 ] ] , // lateral and bottom faces [ for(i=[0:m-1]) i, n*m+1, n*m ], [ for(i=[m-1:-1:0]) -m+i+n*m, n*m+3, n*m+2 ], [ for(i=[n-1:-1:0]) i*m, n*m, n*m+3 ], [ for(i=[0:n-1]) i*m+m-1, n*m+2, n*m+1 ], [n*m, n*m+1, n*m+2, n*m+3 ] ]; polyhedron(points, faces, convexity); } Em qui, 4 de jul de 2019 às 17:16, Ari Diacou <ari.diacou@gmail.com> escreveu: > I have a logo i want to use as a stamp. Is there any way I can use > surface() without having to specify a filename? I'd like to have it in my > library file and not have dependencies (since i call the file from > different computers on my network). > > //For example: > array = [[barf],[hurk],[sick]]; > surface(array); > > Thanks, > --Ari MD > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
C
caterpillar
Fri, Jul 5, 2019 4:01 AM

It sounds like what my px_xxx functions are doing recently.
https://github.com/JustinSDK/dotSCAD/tree/v2

If you can turn your logo into a polygon, px_polygon might help you. For
example:
https://openhome.cc/eGossip/OpenSCAD/lib2-px_polygon.html

http://forum.openscad.org/file/t1825/lib2-px_polygon-1.jpg


http://openhome.cc

Sent from: http://forum.openscad.org/

It sounds like what my px_xxx functions are doing recently. https://github.com/JustinSDK/dotSCAD/tree/v2 If you can turn your logo into a polygon, px_polygon might help you. For example: https://openhome.cc/eGossip/OpenSCAD/lib2-px_polygon.html <http://forum.openscad.org/file/t1825/lib2-px_polygon-1.jpg> ----- http://openhome.cc -- Sent from: http://forum.openscad.org/
AD
Ari Diacou
Sun, Jul 14, 2019 12:33 PM

Thanks all.
Ronaldo, I never get over your ability to use polygon/polyhedron for
EVERYTHING.

On Fri, Jul 5, 2019 at 12:02 AM caterpillar caterpillar@openhome.cc wrote:

Thanks all. Ronaldo, I never get over your ability to use polygon/polyhedron for EVERYTHING. On Fri, Jul 5, 2019 at 12:02 AM caterpillar <caterpillar@openhome.cc> wrote: > It sounds like what my px_xxx functions are doing recently. > https://github.com/JustinSDK/dotSCAD/tree/v2 > > If you can turn your logo into a polygon, px_polygon might help you. For > example: > https://openhome.cc/eGossip/OpenSCAD/lib2-px_polygon.html > > <http://forum.openscad.org/file/t1825/lib2-px_polygon-1.jpg> > > > > ----- > http://openhome.cc > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
RP
Ronaldo Persiano
Sun, Jul 14, 2019 1:15 PM

Ronaldo, I never get over your ability to use polygon/polyhedron for
EVERYTHING.

I have two daughters playing with patchwork. I have enjoyed myself weaving
and origami a lot. My mother was a dressmaker. Sewing is in my DNA. :)

It could be reproduced with the union of 2*(n-1)*(m-1) piramids and the
same number of truncated prisms for a nxm input matrix; a hard 3D patchwork
anyway but with a longer render time.

I have included the code in the Tips&Tricks section of the manual.

> Ronaldo, I never get over your ability to use polygon/polyhedron for > EVERYTHING. > I have two daughters playing with patchwork. I have enjoyed myself weaving and origami a lot. My mother was a dressmaker. Sewing is in my DNA. :) It could be reproduced with the union of 2*(n-1)*(m-1) piramids and the same number of truncated prisms for a nxm input matrix; a hard 3D patchwork anyway but with a longer render time. I have included the code in the Tips&Tricks section of the manual. >