to draw a cylinder in 3d , given its endpoints.

Hi ,
we are trying to draw a cylinder , given its two endpoints.we tried to do it by converting from Cartesian system to Spherical system.

first we draw the cylinder on the origin and then we translated the cylinder to the point whose z-value is close to the origin.then we rotated the cylinder twice .once in y for angle theta(angle of ascension) and phi(angle of declination).
it seems perfect on paper , but the cylinders are not correctly.they start from the first point and do not join the other point.

theta is from 0 - 360 and phi is from 0-180 and am using atan2 and atan to calculate them .should the angles be offsetted with 90/180 ?

are we doing it right ?