Creating a cylinder between two points
or a plane/disk perpendicular to a line
Written by Paul Bourke
There are a number of 3D geometric construction techniques that require a coordinate system perpendicular to a line segment, some examples are:
Creating a disk given its center, radius and normal.
Forming a cylinder given its two end points and radii at each end.
Creating a plane coordinate system perpendicular to a line.
A straightforward method will be described which facilitiates each of these. The key is deriving a pair of orthonormal vectors on the plane perpendicular to a line segment P1, P2.
1. Choose any point P randomly which doesn't lie on the line through P1 and P2
2. Calculate the vector R as the cross product between the vectors P - P1 and P2 - P1. This vector R is now perpendicular to P2 - P1. (If R is 0 then 1. wasn't satisfied)
3. Calculate the vector S as the cross product between the vectors R and P2 - P1. This vector S is now perpendicular to both R and the P2 - P1.
4. The unit vectors ||R|| and ||S|| are two orthonormal vectors in the plane perpendicular to P2 - P1.
Points on the plane through P1 and perpendicular to n = P2 - P1 can be found from linear combinations of the unit vectors R and S, for example, a point Q might be
Qx = P1x + alpha Rx + beta Sx
Qy = P1y + alpha Ry + beta Sy
Qz = P1z + alpha Rz + beta Sz
Creating a cylinder or plane/disk perpendicular to a line segment
file:///F|/Geometry/Display 09 Algorithms/Creating a cylinder or plane-disk perpendicular to a line segment.htm (1 of 2) [12/22/2000 03:43:02 PM]
for all alpha and beta.
A disk of radius r, centered at P1, with normal n = P2 - P1 is described as follows
Qx = P1x + r cos(theta) Rx + r sin(theta) Sx
Qy = P1y + r cos(theta) Ry + r sin(theta) Sy
Qz = P1z + r cos(theta) Rz + r sin(theta) Sz
for 0 <= theta <= 2 pi
The following is a simple example of a disk and the C source stub that generated it.