New paste Repaste Download
// 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);
Filename: None. Size: 448b. View raw, , hex, or download this file.

This paste expires on 2024-10-17 00:57:48.064701. Pasted through web.