Wrapping a pattern around a surface

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

Wrapping a pattern around a surface

leebc
Let's say I want to make a cube and cover it in a tiling-stone or "diamond steel" pattern.  Is there a good method for that?  
What if I want to put this pattern on the curved surface of a cylinder, or
a cone?


Example: I want to design a textured stone tower that is slightly conical,
with a flat top.


I remember reading a few months back that someone had a way to wrap text
around a cylinder...

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

Re: Wrapping a pattern around a surface

JordanBrown
On 9/2/2020 10:56 PM, Bryan Lee wrote:
Let's say I want to make a cube and cover it in a tiling-stone or "diamond steel" pattern.  Is there a good method for that?  
What if I want to put this pattern on the curved surface of a cylinder, or
a cone?


Example: I want to design a textured stone tower that is slightly conical,
with a flat top.


I remember reading a few months back that someone had a way to wrap text
around a cylinder...

First, if you're thinking of painting a texture onto something... can't do it.  Colors are the only kind of paint.

If you're thinking of modeling in some texture, there might be libraries but mostly it's just work.

If you just want to place little bits of texture along a surface, depending on the surface that's not hard.  If you want to bend the texture around the surface, that's harder.

Here's a simplistic module that covers a cylinder with a given bit of texture.
// h, d, and r are the dimensions of the cylinder.
// hinterval is the horizontal interval of the pattern.
// vinterval is the vertical interval of the pattern.
// Both intervals are rounded up to yield an integer number of repeats.
module textured_cylinder(h, d, r, hinterval, vinterval) {
    // Get d and r based on either d or r.
    d = d ? d : r*2;
    r = r ? r : d/2;
    cylinder(h=h, r=r);
    circ = d*PI;                // circumference
    nh = floor(circ/hinterval); // number around
    nv = floor(h/vinterval)+1;  // number up and down
    for (vi = [0:nv-1]) {
        z = vi*h/nv;            // Z position of this row
        for (hi = [0:nh-1]) {
            a = hi*360/nh;      // angle of this instance
            rotate(a) translate([r,0,z]) children();
        }
    }
}

textured_cylinder(h=100,r=20, hinterval=5, vinterval=5) {
    sphere(1);
};


Note that the [0,0,0] of the child is at the edge of the cylinder, and +X is directly "out" of the cylinder.  Thus, for instance, to make a spiky cylinder:

textured_cylinder(h=100,r=20, hinterval=5, vinterval=5) {
    rotate([0,90,0]) cylinder(h=5,r1=3,r2=0);
};

Each child looks like so:


and the result looks like so:


This looks OK, but isn't really quite right, since the cones are based at the edge of the cylinder, and have flat bottoms, and the cylinder is curved:

To correct, move the cones a bit -X so that their base is inside the cylinder.

translate([-1,0,0]) rotate([0,90,0]) cylinder(h=5,r1=3,r2=0);

Mapping to cones or more exotic surfaces is left as an exercise for the reader.  (But for cones is mostly interpolation on the radius, and adjusting the number of iterations based on the circumference at each Z level.)

For a cone getting an aesthetically pleasing pattern might be tough, because the obvious rectangular pattern will have to change frequency as you walk up the cone.

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

Re: Wrapping a pattern around a surface

JordanBrown
Sigh, there's a fencepost error in the vertical stepping.

I had it right the first time, but then when I went back to add comments I "simplified" it a bit and introduced an error.

Better, but harder to describe:
    nv = floor(h/vinterval);
    for (vi = [0:nv]) {

Note that there are multiple "right" answers depending on the edge behavior that you want.


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

Re: Wrapping a pattern around a surface

OpenSCAD mailing list-2
In reply to this post by leebc
Many moons ago, I came across a discussion for creating a  lithophane on a
cylinder via OpenSCAD
<https://openhome.cc/eGossip/OpenSCAD/2DtoCylinder.html>  . I suspect that
this may solve some of the question.

There is also a  video of the principles involved
<https://www.youtube.com/watch?v=PNcGNqMUl5I>  .

Eric Buijs is narrating the video and has a clear presentation, while the
web page link also covers a number of possibly useful aspects.



--
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: Wrapping a pattern around a surface

frankv
In reply to this post by JordanBrown
Maybe this might be useful?

https://www.thingiverse.com/thing:1668883

You can design your texture using any 2d graphics app, then wrap it round the surface. In the case of a cube, you would need to apply the texture to each surface separately. 


On Fri, 4 Sep 2020, 4:08 am Jordan Brown, <[hidden email]> wrote:
On 9/2/2020 10:56 PM, Bryan Lee wrote:
Let's say I want to make a cube and cover it in a tiling-stone or "diamond steel" pattern.  Is there a good method for that?  
What if I want to put this pattern on the curved surface of a cylinder, or
a cone?


Example: I want to design a textured stone tower that is slightly conical,
with a flat top.


I remember reading a few months back that someone had a way to wrap text
around a cylinder...

First, if you're thinking of painting a texture onto something... can't do it.  Colors are the only kind of paint.

If you're thinking of modeling in some texture, there might be libraries but mostly it's just work.

If you just want to place little bits of texture along a surface, depending on the surface that's not hard.  If you want to bend the texture around the surface, that's harder.

Here's a simplistic module that covers a cylinder with a given bit of texture.
// h, d, and r are the dimensions of the cylinder.
// hinterval is the horizontal interval of the pattern.
// vinterval is the vertical interval of the pattern.
// Both intervals are rounded up to yield an integer number of repeats.
module textured_cylinder(h, d, r, hinterval, vinterval) {
    // Get d and r based on either d or r.
    d = d ? d : r*2;
    r = r ? r : d/2;
    cylinder(h=h, r=r);
    circ = d*PI;                // circumference
    nh = floor(circ/hinterval); // number around
    nv = floor(h/vinterval)+1;  // number up and down
    for (vi = [0:nv-1]) {
        z = vi*h/nv;            // Z position of this row
        for (hi = [0:nh-1]) {
            a = hi*360/nh;      // angle of this instance
            rotate(a) translate([r,0,z]) children();
        }
    }
}

textured_cylinder(h=100,r=20, hinterval=5, vinterval=5) {
    sphere(1);
};


Note that the [0,0,0] of the child is at the edge of the cylinder, and +X is directly "out" of the cylinder.  Thus, for instance, to make a spiky cylinder:

textured_cylinder(h=100,r=20, hinterval=5, vinterval=5) {
    rotate([0,90,0]) cylinder(h=5,r1=3,r2=0);
};

Each child looks like so:


and the result looks like so:


    

This looks OK, but isn't really quite right, since the cones are based at the edge of the cylinder, and have flat bottoms, and the cylinder is curved:

To correct, move the cones a bit -X so that their base is inside the cylinder.

translate([-1,0,0]) rotate([0,90,0]) cylinder(h=5,r1=3,r2=0);

Mapping to cones or more exotic surfaces is left as an exercise for the reader.  (But for cones is mostly interpolation on the radius, and adjusting the number of iterations based on the circumference at each Z level.)

For a cone getting an aesthetically pleasing pattern might be tough, because the obvious rectangular pattern will have to change frequency as you walk up the cone.
_______________________________________________
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

ddfijdnmiipobgej.png (6K) Download Attachment
hmoolghpihkgecek.png (3K) Download Attachment
plemnhhokbncmeoa.png (14K) Download Attachment
jchnhnklliecidaj.png (3K) Download Attachment
pkjldgonoldeklii.png (3K) Download Attachment
ddfijdnmiipobgej.png (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Wrapping a pattern around a surface

caterpillar
In reply to this post by leebc
If you want to wrap a pattern around a surface and implement it by yourself,
you have to know more about your surface.  Depends on your surfaces, some
jobs are not easy.

Basically, wrapping a pattern around a surface involves transforming 2D
points into 3D points.

If you just want to see if someone has implemented it, I created some
functions for doing some of these jobs.
https://github.com/JustinSDK/dotSCAD#point-transformation

I also created some modules for wrapping a photo around some surfaces.
https://github.com/JustinSDK/dotSCAD#surface



-----
https://openhome.cc
--
Sent from: http://forum.openscad.org/

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