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

• Jul 20th 2010, 03:05 AM
averagebrain
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.
• Jul 22nd 2010, 10:47 AM
earboth
Quote:

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:

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

where $\displaystyle \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 $\displaystyle \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.