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.