0
$\begingroup$

I have a 3-dimensional view, where I have drawn a line $L$. I know the line direction vector $(x,y,z)$, where $L$ is also the center of a cylinder with given radius $r$.

I wish, based on the radius $r$ and direction vector $(x,y,z)$ to draw the cylinder. For that, given my working environment capabilities, I only need to calculate the points of the two disks which are the limits of the cylinder.

For that, I have the $(x_1,y_1,z_1)$, $(x_2,y_2,z_2)$ which are the coordinates of the start and the end of the cylinder center on the line $L$.

I need to take calculate all points of the disks that are orthogonal to the line L and which have their center at either $(x_1,y_1,z_1)$, or $(x_2,y_2,z_2)$, having radius $r$. Of course, everything is descrete, so 360 points (going with difference of $1^\circ$) is good enough.

1 Answers 1

1

For each of the disks you have two constraints:

point on the edge of the disk $(x_e, y_e, z_e)$ must be in the distance of $r$ of the disk origin $(x_1, y_1, z_1)$ i.e. $(x_1-x_e)^2+ (y_1-y_e)^2+ (z_1-z_e)^2 = r^2$

and also the disk must be orthogonal to the line, so, knowing that scalar product gives 0 iff the two vectors are orthogonal you get: $(x_1-x_e, y_1-y_e, z_1-z_e)\cdot(x,y,z) = (x_1-x_e)x+ (y_1-y_e)y+ (z_1-z_e)z = 0$ .

With given values of disk origin $(x_1, y_1, z_1)$ and line direction $(x, y, z)$ it becomes a simple quadratic eqation.

  • 0
    first equation gives you a sphere with radius $r$ around $(x_1, y_1, z_1)$, the second one gives you a plane orthogonal to $(x, y, z)$ and going through $(x_1, y_1, z_1)$. The intersection of these two constraints is the searched circle. Solve second equation for one variable, put it into first equation.2012-12-12