surface without import?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

surface without import?

drxenocide
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: surface without import?

MichaelAtOz
Administrator
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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!
Reply | Threaded
Open this post in threaded view
|

Re: surface without import?

Ronaldo
In reply to this post by drxenocide
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: surface without import?

caterpillar
In reply to this post by drxenocide
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: surface without import?

drxenocide
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: surface without import?

Ronaldo

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.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org