0
$\begingroup$

Given the 3d coordinates of the 2 spheres (see image below) and the length of the Box, how can find the 3d coordinates at the end of the box using an equation?

enter image description here

  • 0
    the box and 2 spheres are on a straight line2012-02-11

1 Answers 1

3

If the coordinates of the center of the blue sphere are $B=(B_x,B_y,B_z)$ and the coordinates of the center of the green sphere are $G=(G_x,G_y,G_z)$, then the vector $\overrightarrow{BG}=G-B=\langle G_x-B_x,G_y-B_y,G_z-B_z\rangle$ and we can unitize that vector (create a vector of length 1 in the same direction by taking $\vec{n}=\frac{\overrightarrow{BG}}{\|\overrightarrow{BG}\|}=\left\langle\frac{G_x-B_x}{\|\overrightarrow{BG}\|},\frac{G_y-B_y}{\|\overrightarrow{BG}\|},\frac{G_z-B_z}{\|\overrightarrow{BG}\|}\right\rangle$ where $\|\overrightarrow{BG}\|=\sqrt{(G_x-B_x)^2+(G_y-B_y)^2+(G_z-B_z)^2}$.

Now, the distance from the center of the green sphere to the middle of the far end of the box is the length of the box plus the radius of the sphere. Let's call that total distance $d$. The vector $d\vec{n}$ will have length $d$ and be in the same direction as the vector from B to G, which is along the line through the centers of the spheres. If we add $d\vec{n}$ to $G$, we'll get the coordinates of the center of the far end of the box: $\begin{align} G+d\vec{n} &=(G_x,G_y,G_z)+d\left\langle\frac{G_x-B_x}{\|\overrightarrow{BG}\|},\frac{G_y-B_y}{\|\overrightarrow{BG}\|},\frac{G_z-B_z}{\|\overrightarrow{BG}\|}\right\rangle \\ &=\left\langle G_x+d\cdot\frac{G_x-B_x}{\|\overrightarrow{BG}\|},G_y+d\cdot\frac{G_y-B_y}{\|\overrightarrow{BG}\|},G_z+d\cdot\frac{G_z-B_z}{\|\overrightarrow{BG}\|}\right\rangle. \end{align}$

  • 0
    @Unni: I took that to be the case from the original poster's comment on the question that "the box and 2 spheres are on a straight line" (which I realize doesn't necessarily mean the same thing, but it seemed like the most likely interpretation).2012-02-18