Wrap the image around the cylinder

Someone recently asked me if I could print a bracelet with a custom image engraved on his face.

For me, the problem is simple: I have a 2d Cartesian system (x, y) that expresses the points of a vectorized image sent by me by a person. I want to consider them as a three-dimensional cylindrical system (theta, r, z '), where r is constant. Finally, I want to convert this three-dimensional cylindrical system into a 3D Cartesian system (x ', y', z ') in the usual way.

So:

z' = y
y' = r cos(x)
x' = r sin(x)

The problem is that I do not know how to express this in OpenSCAD. There is an option to transform the matrix using multmatrix (), but this only allows linear transformation - i.e. I cannot express things like cos (x), at least as far as I know.

I want either:

  • an existing module / hack to express this transformation, or

  • general method for performing transforms on vertices, like the vertex shader in glsl

At least can it be confirmed that such things are not available in OpenSCAD?

+1
source share
1 answer

surface(), . http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Surface. script , . 'Surface.dat. difference().

"surface.dat"

difference() {
translate([0,0,5])cube([10,10,10], center =true);
rotate([0,0,90])surface(file = "surface.dat", center = true, convexity = 5);}

28.10.2014: pixeldata for . (x), (y) greyvalue/255 . , , , . (x) . . python3.4, PyQt5 Qt.QtGui.QImage. openscad 2000 . "//"

opencad- script:

include <./matrix_p.scad>;
difference() {
    translate([-b,0,0]) rotate([0,90,0]) difference() {
        cylinder(h = hb, r = rb, center = false);
        translate([0,0,-0.5]) cylinder(h = hb+1, r = rb-tb, center = false);
    } 
    for (val = m)
    rotate([-ap*val[0],0,0]) translate([0,-rb-0.1,-ps/2]) linear_extrude(height = ps) polygon(points = val[1]);
}

matrix_p.scad:

// userinput
rb = 50;                    //radius bracelet
tb = 5;                     //thickness of b.
hb = 80;                    //height of b.
b = 10;                     //borderwidth beside engraving
// input from Qt.QtGui.QImage
iw = 590;                   //imagewidth in pixel
ih = 726;                    //height in pixel
ps = (hb-2*b)/ih;           //scaling of pixel to fill the free place
ap = (ps*180)/(PI*rb);      //angle per pixel

0

Source: https://habr.com/ru/post/1662989/


All Articles