# Math Help - Finding coordinates of lines on edge of cylinder given midpoint line

1. ## Finding coordinates of lines on edge of cylinder given midpoint line

Hello, I'm trying to write a script to generate approximate 3D cylinders and this problem is stumping me.

I start with a line segment AB in 3D space defined by xyz coords at points A and B. These coordinates are known.

What then is a formula for finding the xyz coords of two points C and D defining a line segment CD exactly parallel to and of the same length as AB, given (i) a perpendicular distance d from AB and (ii) an arbitrary rotation around AB? In other words, you can think of CD as lying on the edge of a cylinder, a cylinder which has AB as its central line and d as its radius; having defined the coords of one solution for CD, I need to find another solution at a given rotation around the edge of this cylinder.

I hope that makes sense - I can scan in a drawing if that helps.

2. Originally Posted by averagebrain
Hello, I'm trying to write a script to generate approximate 3D cylinders and this problem is stumping me.

I start with a line segment AB in 3D space defined by xyz coords at points A and B. These coordinates are known.

What then is a formula for finding the xyz coords of two points C and D defining a line segment CD exactly parallel to and of the same length as AB, given (i) a perpendicular distance d from AB and (ii) an arbitrary rotation around AB? In other words, you can think of CD as lying on the edge of a cylinder, a cylinder which has AB as its central line and d as its radius; having defined the coords of one solution for CD, I need to find another solution at a given rotation around the edge of this cylinder.

I hope that makes sense - I can scan in a drawing if that helps.
The bad news first: This is NOT a complete solution of your problem - but maybe you can take my considerations and go a little bit further.

1. The line AB is the axis of the cylinder. Then AB is perpendicular to the plane which contains the base circle of the cylinder. The equation of this plane is:

$\overrightarrow{AB} \cdot ((x,y,z) - \vec a)=0$

where $\vec a$ is the staionary vector of the point A and (x, y, z) are the coordinates of any point in the plane.

2. The point C is placed on the circle line around A with radius d in the above mentioned plane.

3. The point D has the staionary vector $\vec d = \vec c + \overrightarrow{AB}$

4. What you need is the equation of a circle in 3-D in relation to the "tilt" of AB.