# Rotation problem.

6 messages
Open this post in threaded view
|

## Rotation problem.

 Hi to all, I have done some work on OpenSCAD to make a duct for cooling my electronics, now I'm facing a problem, the duct is OK, but I have not figure out how to position the other components. duct(2,[15,15],50,0,50,[80,80],45,15); module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){     difference(){                 port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);                 scale(1.01)                 port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe);     } } module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){     hull() {         echo(xy_a,,off_x,off_z,xy_b,angle_b);         cube([xy_a.x+d*2,xy_a.y+d*2,pipe],center=true);         translate([off_x,off_y,off_z])         rotate([0,angle_b,0])         cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true);    } } want a mean to place an object on the xy_b cube in my case the fan mount but I didn't find a manner to properly place in this position. I have thought of replicate the lines         translate([off_x,off_y,off_z])         rotate([0,angle_b,0])         cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); but I need some advice, I could think i have to make some trigonometrics transformation on the rotate part to match the angles, as the only thing I have managed to is to make the "cube" but it is shifted and didn't match the duct. Sorry for my bad english TIA and Regards Carlo D. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rotation problem.

Open this post in threaded view
|

## Re: Rotation problem.

 In reply to this post by onekk On 5/5/2018 1:12 AM, onekk wrote: ```Hi to all, I have done some work on OpenSCAD to make a duct for cooling my electronics, now I'm facing a problem, the duct is OK, but I have not figure out how to position the other components. duct(2,[15,15],50,0,50,[80,80],45,15); module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){ difference(){ port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); scale(1.01) port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); } } module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){ hull() { echo(xy_a,,off_x,off_z,xy_b,angle_b); cube([xy_a.x+d*2,xy_a.y+d*2,pipe],center=true); translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); } } want a mean to place an object on the xy_b cube in my case the fan mount but I didn't find a manner to properly place in this position. I have thought of replicate the lines translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); but I need some advice, I could think i have to make some trigonometrics transformation on the rotate part to match the angles, as the only thing I have managed to is to make the "cube" but it is shifted and didn't match the duct. ``` When you say ""on the xy_b cube", what exactly do you mean? Remember that the xy_b cube is centered. ``` translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) (some object) ``` will put the 0,0,0 point for the object at the same point as the 0,0,0 point of the xy_b cube.  Is that what you want?  If not, you'll probably want to translate it, before the rotate and translate and translate that put it into the final location. For instance, here's a 10x10x10 cube floating on the surface of the xy_b cube. ```duct(2,[15,15],50,0,50,[80,80],45,15); module duct(thick,xy_a=[80,80],off_x,off_y,off_z,xy_b=[10,20],angle_b,pipe){ difference(){ port(thick,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); scale(1.01) port(0,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe); } // Add a floating cube above the wide end. // Note the inner translate that moves the floater to // rest atop the "b" cube. floater_size = 10; translate([off_x, off_y, off_z]) rotate([0, angle_b, 0]) translate([0, 0, pipe/2 + floater_size/2]) cube([floater_size, floater_size, floater_size], center=true); } module port(d,xy_a,off_x,off_y,off_z,xy_b,angle_b,pipe){ hull() { echo(xy_a,,off_x,off_z,xy_b,angle_b); cube([xy_a.x+d*2,xy_a.y+d*2,pipe],center=true); translate([off_x,off_y,off_z]) rotate([0,angle_b,0]) cube([xy_b.x+d*2,xy_b.y+d*2,pipe],center=true); } } ``` _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Rotation problem.

 In reply to this post by onekk For better printing you might want to orientate the design with the large cube staying at the xy-plane. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org