Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question
    
What are the conditions on the shapes? Is it that the box is tangent to the green sphere, and the long edge of the box is parallel to the line between the two spheres? –  Lopsy Feb 11 '12 at 15:44
    
the box and 2 spheres are on a straight line –  Nips Feb 11 '12 at 15:55

1 Answer 1

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}$$

share|improve this answer
    
The point which I wanted add is : For the above solution to work the line joining the center of the green and blue sphere has to be parallel to the box. This is not specified explicitly in the question. –  PermanentGuest Feb 17 '12 at 15:59
    
@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). –  Isaac Feb 18 '12 at 22:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.