Skip to content

Instantly share code, notes, and snippets.

@wware
Last active August 3, 2018 19:50
Show Gist options
  • Save wware/875998248c23ebd86668fd5c354ec737 to your computer and use it in GitHub Desktop.
Save wware/875998248c23ebd86668fd5c354ec737 to your computer and use it in GitHub Desktop.
OpenSCAD code to create a cylinder connecting two given points in 3-space
v1 = [0, 2, -1];
v2 = [1, 3, 3];
y = [v2[0] - v1[0], v2[1] - v1[1], v2[2] - v1[2]];
translate(v1)
rotate(-acos(y[2] / norm(y)), cross(y, [0, 0, 1]))
cylinder(h=norm(y), d=0.1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment