// View, Animate, FPS: 30, Steps: 300 // 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(); } ax = $t*360*5; ay = $t*360*7; v = 10*(cos(ax)*sin(ay)+3)*[cos(ax), sin(ay), cos(ax+ay)+1]; RotateFromTo([1,0,0], v) rotate([0, 90, 0]) { translate([-4, 4, 4]) sphere(r=2); translate([-4, -4, 4]) sphere(r=2); difference() { cylinder(r=10, h=5); translate([3, 0, 5]) sphere(r=3); } } translate(v) sphere(5);