What is the equation of points equally distant to a line segment 3D space?

75 Views Asked by At

The points equally distant to a point form a sphere in 3D with equation: $$x^2+y^2+z^2=r^2$$

Now say that I have two points $A(x_1,y_1,z_1), B(x_2, y_2, z_2)$ that are on a line with equation: $$x=x_0+ta\\y=y_0+tb\\z=z_0+tc$$

What would be the equation for the points equally distant to the line segment? It should look like a pill (a cylinder with a hemisphere at either end), but I don't know how to describe it mathematically.

3

There are 3 best solutions below

3
On BEST ANSWER

First form the unit vector from $A$ to $B$. This is given by

$ N = \dfrac{B - A}{\| B - A \| } $

Second, find any vector in $3D$ that is perpendicular to $N$, let's call it $V_1$.

Third, compute the vector $V_2 = N \times V_1 $

Now the desired locus of the points that are at the same distance $r$ from the segment $AB$ is the union of three regions in space: region $R_1$ given by

$ R_1 = \{ (x, y, z) | (x, y, z) = (1 - t) A + t B + r V_1 \cos s + r V_2 \sin s , 0 \le t \le 1, 0 \le s \le 2 \pi \} $

and region $R_2$ given by

$ R_2 = \{ (x, y, z) | (x, y, z) = A + r ( \sin t \cos s \ V_1 + \sin t \sin s \ V_2 - \cos t \ N ) , 0 \le t \le \pi , 0 \le s \le 2 \pi \} $

and region $R_3$ given by

$ R_3 = \{ (x, y, z) | (x, y, z) = B + r ( \sin t \cos s \ V_1 + \sin t \sin s \ V_2 + \cos t \ N ) , 0 \le t \le \pi , 0 \le s \le 2 \pi \} $

0
On

About the cylinder issue, I will recall (and fill the blanks in) an answer of Zorn here :

$$|\vec{x} - \vec{x}_1|^{2} = R^{2} + [(\vec{x} - \vec{x}_1)\bullet \vec{v}]^{2}\tag{1}$$

Indeed, to an infinite cylinder passing through point $M_1=(x_1,y_1,z_1)$, with axis defined by unit vector $\vec{v}=(a,b,c)$, and radius $R$, one can apply Pythagoras' theorem to the triangle with vertices $X=(x,y,z)$ (the generic point on the cylinder) and $X'$ (the orthogonal projection of $X$ onto the axis). We have

$$\begin{cases}XX'&=&R\\ \vec{M_1X}&=&(x-x_1,y-y_1,z-z_1)\\ M_1X'&=&\vec{M_1X} \bullet \vec{v}\end{cases}$$

The last equation only deserves an explanation : it is due to the fact that the length of the projection of a line segment $AB$ onto an axis with unit directing vector $\vec{v}$ is equal to the absolute value of the dot product $\vec{AB} \bullet \vec{v}$.

(1) can be written explicitly :

$$(x-x_1)^2+(y-y_1)^2+(z-z_1)^2=R^2+((x-x_1)a+(y-y_1)b+(z-z_1)c)^2\tag{2}$$

which is in fact a necessary and sufficient condition for a point $(x,y,z)$ to belong to the cylinder ; otherwise said, (2) is the equation of the cylinder.

Please note that (2) is a second degree expression, which is what one can expect. Indeed, a circular cylinder is a quadric, like the end-spheres. But together (cylinder + spheres) the capsule isn't a quadric and hasn't even an algebraic equation.

Remark : if $\vec{v}=(a,b,c)$ hasn't been normalized, its coordinates should be divided by $\sqrt{a^2+b^2+c^2}$ ; in a reciprocal way, one can write the equation of the cylinder in the case of an unnormalized directing vector under the (homogeneous and more symmetrical) form

$$((x-x_1)^2+(y-y_1)^2+(z-z_1)^2-R^2)(a^2+b^2+c^2)=((x-x_1)a+(y-y_1)b+(z-z_1)c)^2\tag{3}$$

0
On

I think you are asking for equations that describe points B on the body of the pill shape, and points C on the end of the pill shape

fig1

Mathematically, the above are described by the following two vector equations

$$\left\Vert \boldsymbol{B}-\boldsymbol{\hat{x}}\left(\boldsymbol{\hat{x}}^{\intercal}\boldsymbol{B}\right)\right\Vert =R \tag{1}$$

where $\boldsymbol{B}$ is the vector coordinates of point B, $\boldsymbol{\hat{x}}$ is the direction vector along the pill, and $R$ the radius of the pill ends.

and

$$\left\Vert \boldsymbol{C}-\boldsymbol{\hat{x}}\frac{\ell}{2}\right\Vert =R \tag{2}$$

where $\ell$ is the body length of the pill (center-to-center). Also $\| \|$ is the Euclidian norm $\sqrt{x^2+y^2+z^2}$ of a vector.

You can parametrize half the pill (shown above in white) with

$$\boldsymbol{B}(t,\theta)=R\left(\boldsymbol{\hat{y}}\cos\theta+\boldsymbol{\hat{z}}\sin\theta\right)+t\,\frac{\ell}{2}\boldsymbol{\hat{x}}$$ with $t=0 \ldots +1$ and $\theta = 0 \ldots 2\pi$

and

$$\boldsymbol{C}(\psi,\varphi)=R\left(\boldsymbol{\hat{x}}\cos\psi+\boldsymbol{\hat{y}}\sin\psi\cos\varphi+\boldsymbol{\hat{z}}\sin\psi\sin\varphi\right)$$

for $\varphi = 0 \ldots 2\pi$ and $\psi = -\tfrac{\pi}{2} \ldots +\tfrac{\pi}{2}$

To get the red side, just reverse the $\boldsymbol{\hat{x}}$ axis, but taking the negative of the coefficient in front of the axis vector.