// Rotate children to reorient vector "from" toward "to". // Uses the rotation which preserves the xy plane orientation. module RotateFromTo(from, to) { rotate([0, 0, atan2(to[1], to[0])]) rotate([0, -atan2(sqrt(to[0]^2 + to[1]^2), -to[2]), 0]) rotate([0, atan2(sqrt(from[0]^2 + from[1]^2), -from[2]), 0]) rotate([0, 0, -atan2(from[1], from[0])]) children(); } RotateFromTo([0,0,1], [1,0,0]) cylinder(r=10, h=5);