# Images on curved (cylindrical) surface

11 messages
Open this post in threaded view
|

## Images on curved (cylindrical) surface

 This post has NOT been accepted by the mailing list yet. CONTENTS DELETED The author has deleted this message.
Open this post in threaded view
|

## Re: Images on curved (cylindrical) surface

 Administrator Lukas wrote Hi, I am just getting started with OpenSCAD and just found the feature to import images via an Inkscape extension. But the tutorials I found only show the import/editing of flat images. Is there any chance to put this flat image onto a curved surface such as a cylinder? Hope the question makes sense... Thanks, Lukas AFAIK no, not if you mean like wrapping a label around an object. If the image is like a line drawing, you could linear_extrude it & intersect it with a hollow cylinder, but the result would be contorted. Or you could slice it up and move the bits around, but the maths would be beyond me. 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.
Open this post in threaded view
|

## Re: Images on curved (cylindrical) surface

 This post was updated on . And it would be so easy, once one could get (programmatically) hands on the DXF representation in OpenSCAD ...   But there is also a programmatic solution with current OpenSCAD using some windowing technique for discretization. Not the fastest but viable:   R = 45;  // radius H = 2;   // height L = 130; // centering offset step = 5; \$fn=360/step; for (i=[0:step:360]) {   radian = R*PI/180;   rotate([0, i, 0])   translate([0,0,R-H/2]) // cylinder stuff   intersection()   {     translate([L-i*radian, 0, 0])  // shift dxf over the window     linear_extrude(height = H, center = true, convexity = 4)     import("geschafft.dxf");     cube([radian*step, 100, H+1], center = true);  // window   } } color("black", .7) rotate([90, 0, 0]) cylinder(r=R-H, h = 100, center = true); geschafft.dxf
Open this post in threaded view
|

## Re: Images on curved (cylindrical) surface

 But there is also a programmatic solution with current OpenSCAD using some windowing technique for discretization. Not the fastest but viableI've got code for making pasta / pastry cutting rollers which imprint a tessellating image on the surface of a cylinder. The simplest version is one where the image needs no rotation and can tessellate by simple translation: http://www.thingiverse.com/thing:1640712It uses hull operations to combine two cylinders at interpolated points derived from the source polygon. Unfortunately I need to have an explicitly-defined source polygon at the moment, as I couldn't find a way in OpenSCAD to extract polygon paths from arbitrary objects. This can be extracted from SVG paths and pasted into the OpenSCAD code, but it's not particularly easy for a first-timer to do that.     pr=20; // pattern radius     pi=3.1415927;     cr=3*pr/sin(60)/(2*pi); // cylinder radius     pf=0.2; // relative size of edge points         // Flattens an array down one level (removing the enclosing array)     function flatten(pointArray, done=0, res=[]) =         (done == len(pointArray)) ?             res :             flatten(pointArray=pointArray, done=done+1,                 res=concat(res,pointArray[done]));                     // linear interpolation between two points, excludes last point     function intp(p1, p2, thr=0.5, res = []) =         (norm(p2-p1) <= thr) ? concat(res,[p1]) :             intp(p1=p1 + (thr/norm(p2-p1)) * (p2-p1), p2=p2,                 thr=thr, res = concat(res,[p1]));         kath_poly = flatten([ for(i=[-30:60:329]) [             [pr*cos(i)-pr*pf*cos(i),pr*sin(i)-pr*pf*sin(i)],             [pr*cos(i),pr*sin(i)],             [pr*cos(i)+pr*pf*cos(i+60),pr*sin(i)+pr*pf*sin(i+60)] ]]);         int_kath = flatten([for(i = [0:(len(kath_poly)-1)])             intp(p1=kath_poly[i], p2=kath_poly[(i+1) % len(kath_poly)], thr=2)]);         cyl_kath = [ for(i = [0:(len(int_kath)-1)])       [(cr)*cos(int_kath[i][0]/cr * 180/pi),(cr)*sin(int_kath[i][0]/cr * 180/pi),-int_kath[i][1]] ];         module 3d_kath(){         for(i = [0:(len(cyl_kath)-1)]){             hull(){                 translate(cyl_kath[i])                     rotate(int_kath[i][0]/cr * 180/pi) rotate([90,0,90])                         translate([0,0,1])                             cylinder(r1=2, r2=0, h=4, \$fn=4, center=true);                 translate(cyl_kath[(i+1) % len(cyl_kath)])                     rotate(int_kath[(i+1) % len(cyl_kath)][0]/cr * 180/pi) rotate([90,0,90])                         translate([0,0,1])                             cylinder(r1=2, r2=0, h=4, \$fn=4, center=true);             }         }     }         module kath_roller(){         cylinder(r=cr, h=110, center=true);         3d_kath();         rotate(180) 3d_kath();         translate([0,0,1.5*pr]) rotate(90) 3d_kath();         translate([0,0,1.5*pr]) rotate(270) 3d_kath();         translate([0,0,-1.5*pr]) rotate(90) 3d_kath();         translate([0,0,-1.5*pr]) rotate(270) 3d_kath();     }     kath_roller();
Open this post in threaded view
|

## Re: Images on curved (cylindrical) surface

 This post was updated on . However it is easy for a first timer to use Inkscape to create the svg and the openscad export tool to create polygon lists. - http://www.thingiverse.com/thing:1065500@david can you adjust your code to take those lists ?
Open this post in threaded view
|

## Re: Images on curved (cylindrical) surface

 This post has NOT been accepted by the mailing list yet. In reply to this post by Parkinbot CONTENTS DELETED The author has deleted this message.
Open this post in threaded view
|

## Re: Images on curved (cylindrical) surface

 In reply to this post by Lukas I was just looking at this problem myself. My starting point was http://www.thingiverse.com/thing:1481 which wraps 3 copies of an image around a cylinder, then extrudes. There's about 15KB of Python source that generates an OpenSCAD file. License on this is "Creative Commons - Attribution - Non-Commercial". The author is Philipp Tiefenbacher (wizard23). I've refactored his code a little, and extended it to include conic surfaces, without really understanding how the underlying stuff works. I haven't finished my tidy-up yet, but I'm happy to share (now or when finished) as per Philipp's license. I'm new to openSCAD & Python (but a long-time programmer) so my "tidy" may be less than your "tidy". I'm equally happy for someone else to finish this off. If all you're interested in is mapping text characters to a cylinder, then http://www.thingiverse.com/thing:1661993 is useful. Frank
Open this post in threaded view
|

## Re: Images on curved (cylindrical) surface

Open this post in threaded view
|

## Re: Images on curved (cylindrical) surface

 When I need to wrap a shape around a cylinder, I cut it in small pieces that I reassemble on the cylinder. The shape (here in orange) can be anything close to flat. Here is the code: w=30; // radius of cylinder h=100; // height of cylinder // // the pattern should be at [w,0,0] and move in y according to a // pattern should be 2Pi * w size in Y // Some rings... // module pattern0(a=0) {     for(i=[0:3]) {         translate([w,a*PI/180*w+i*PI/2*w+w,-20])         rotate([-90,0,-90])         difference() {             cylinder(d1=PI/2*w+3,d2=0,h=80);             translate([0,0,-0.1]) cylinder(d1=PI/2*w-3,d2=45+50,h=80);         }     } } // some text... module pattern1(a=0) {     translate([w,a*PI/180*w,10])     rotate([90,0,90])     linear_extrude(height=5,convexity=2) text("bonjour!",32); } // rings and text... module pattern2(a=0) {     pattern0(a);     pattern1(a); } module cutter(a=5,w=50,h=100) {     render()     intersection() {         rotate([0,0,-a/2]) translate([0,0,-h/2]) cube([w,50,h]);         rotate([0,0,a/2]) translate([0,-50,-h/2]) cube([w,50,h]);     } } %cylinder(r=w,h=h,center=true); color("orange") translate([0,0,0]) pattern2(0); step=5; for( i=[0:step:360+2*step] ) {     rotate([0,0,i])     intersection() {         pattern2(-i);         cutter(step,w+20,h+20);     } }