Here is something I use:

function elen(vec)= sqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]);

function
cprod(a,b)=[a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]];

function dprod(a,b)=a[0]*b[0]+a[1]*b[1]+a[2]*b[2];

function vangle(a,b)=acos(dprod(a,b)/(elen(a)*elen(b)));

module link(a,b,r=3,cr=3){

diff=b-a;

translate(a)sphere(r=cr,center=true,$fn=8);

translate(b)sphere(r=cr,center=true,$fn=8);

translate(a+diff/2)rotate(vangle(diff,[0,0,1]),-cprod(diff,[0,0,1]))cylinder(r=r,h=elen(diff),center=true,$fn=8);

}

link([x1,y1,z1],[x2,y2,z2],r);

will then do what you want.

Remove the spheres if you don't want them.

Kliment

On 06/01/2012 09:18 PM, Joseph Eddy wrote:

Does anyone know of an "easy" way to create a cylinder of
radius r with endpoints at x1, y1, z1 and x2, y2, z2?

I assume there's some way to transform these endpoint
coordinates into some combination of
height/rotation/translation, but the required geometry is
eluding me.

Thanks,

Joe

-------

Sent from my gewgaw.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad