Using cylinders for line drawing

I have been trying to use cylinders for line drawing, unfortunately I have not
been able to get the results I want.
I am sure the problem is something really stupid (either in the Math or holes
on my understanding of the coordinate system).

I want to draw a line given a list of points. Two points will define a line
segment which will be drawn as a cylinder.
What I am getting is lines that do not intersect at the position points (They
are close though).
What am I doing wrong?

Here is my code:
--position_list is a list of 3D vectors
if position_list.count > 1 then

plane_number = 0

first_position = position_list[1]

repeat with position_counter = 2 to position_list.count
second_position = position_list[position_counter]

plane_difference = second_position - first_position
plane_difference_o2 = plane_difference / 2
plane_length = length(plane_difference)

plane_scale = vector(5, plane_length , 1)
plane_rotate = vector(0,0,0)

-- positioning the cylinder between the two points
plane_translate = first_position + plane_difference_o2

dir = plane_difference
dir.normalize()

-- Build rotation around Y
-- Adding 90 to align the cylinder correctly
plane_rotate.z = RadiansToDegrees(atan(dir.y/dir.x)) + 90
plane_rotate.x = RadiansToDegrees(-atan(dir.z/dir.y))

plane_test1 = world_object.newModel("line"&plane_number,
world_object.modelResource("cylinder"))
plane_test1.transform.scale(plane_scale)
plane_test1.transform.rotate(plane_rotate.x,0,plan e_rotate.z)
plane_test1.transform.translate(plane_translate)

plane_number = plane_number + 1

first_position = second_position
end repeat

end if