The unknown point P (x, y, z) in three-dimensional space is at a constant sum of distances dPA and dPB from two known fixed points A and B, i.e., dPA + dPB = constant. How can we express the trajectory of P? I know that in the two-dimensional plane, the trajectory of P would be an ellipse. In three-dimensional space, it seems to be a shape resembling an ellipse that consistently maintains the same major and minor axes regardless of the angle of the cross-section. I would like to use MATLAB to generate N random points on this shape, but I don't have a good method. Can anyone help me with this?
-
If the distance between an unknown point and a known point in space is constant, then it forms a spherical surface. You can generate N sample points with maximum likelihood using the following MATLAB code: r = 1; phi = acos(1 - 2rand(1, 100)); theta = 2pirand(1, 100); x = rsin(phi).cos(theta); y = rsin(phi).sin(theta); z = rcos(phi); However, when the problem becomes the sum of the distances from an unknown point to two known points being constant, I don't know what to do. – ZHIHA Feb 06 '24 at 08:52
2 Answers
Yes, you are correct in noting that the surface is that of an ellipse for each cross-section. The shape is essentially that which is formed by considering the 2D ellipse formed with A and B as focii, and rotating it about the line AB.
To randomly sample points on this ellipsoid, you can use this answer, which gives code for the description provided here
- 351
-
Thank you very much for your response and the help you've provided. So, for this ellipsoid formed by rotating the 2D ellipse around the AB axis, how can I obtain the values of the three parameters a, b, and c for this ellipsoid? I am sorry, it has been a long time since I have been in touch with geometry mathematics, so my question may seem a bit naive. I hope you can understand. – ZHIHA Feb 06 '24 at 09:27
From the givens, let $p = (x,y,z)$ and let the two points be $F_1$ and $F_2$, and let the distance between them be $2 c = \| F_1 - F_2 \|$, and let the sum of distances be $2a$, then
$ \| p - F_1 \| + \| p - F_2 \| = 2 a $
Square this equation, you get
$ (p - F_1) \cdot (p - F_1) + (p - F_2) \cdot (p - F_2 ) + 2 \| p - F_1 \| \| p - F_2 \| = 4 a^2 $
Re-arrange the equation as follows
$ 2 \| p - F_1 \| \| p - F_2 \| = 4 a^2 - (p - F_1) \cdot (p - F_1) - (p - F_2) \cdot (p - F_2 ) $
Simplify the right hand side
$ 2 \| p - F_1 \| \| p - F_2 \| = 4 a^2 - 2 p \cdot p + 2 p \cdot (F_1 + F_2) - F_1 \cdot F_1 - F_2 \cdot F_2 $
At this point introduce the midpoint of $F_1$ and $F_2$:
$ C = \dfrac{1}{2} ( F_1 + F_2 ) $
And let
$ U = \dfrac{1}{2} (F_2 - F_1) $
Then
$ 2 \| p - F_1 \| \| p - F_2 \| = 4 a^2 - 2 p \cdot p + 4 p \cdot C - 2 (C \cdot C + U \cdot U) $
Now, replace $F_1$ and $F_2$ on the left hand side, and re-write them in terms of $C$ and $U$, and divide through by $2$:
$ \| p - C + U \| \| p - C - U \| = 2 a^2 - p \cdot p + 2 p \cdot C - (C \cdot C + U \cdot U ) $
Note that $(p - C) \cdot (p - C) = p \cdot p - 2 p \cdot C + C \cdot C $
Therefore,
$ \| p - C + U \| \| p - C - U \| = 2 a^2 - (p - C)\cdot (p - C) - U.U $
Now let $q = p - C $, then
$ \| q + U \| \| q- U \| = 2 a^2 - q\cdot q - U.U $
Squaring both sides,
$ ( (q + U) \cdot (q + U) )( (q - U) \cdot (q - U) ) = 4 a^4 + (q \cdot q)^2 + (U. U)^2 - 4 a^2 (q \cdot q) - 4 a^2 (U.U) + 2 (U.U) (q \cdot q) $
Expanding the left hand side we get,
$ ( q\cdot q + 2 q\cdot U + U\cdot U)( q\cdot q - 2 q\cdot U + U\cdot U ) = RHS $
Simplifying the left hand side, the equation becomes,
$ (q \cdot q)^2 + (U \cdot U)^2 + 2 (q \cdot q) (U \cdot U) - 4 (q \cdot U)^2 = 4 a^4 + (q \cdot q)^2 + (U. U)^2 - 4 a^2 (q \cdot q) - 4 a^2 (U.U) + 2 (U.U) (q \cdot q) $
Cancelling $(q \cdot q)^2 $ and $(U \cdot U)^2$ and $ 2 (U.U) (q \cdot q) $ on both sides of the equation gives
$ - 4 (q \cdot U)^2 = 4 a^4 - 4 a^2 (q \cdot q) - 4 a^2 (U.U) $
Dividing by $4$ through,
$ - (q \cdot U)^2 = a^4 - a^2 (q \cdot q) - a^2 (U.U) $
Using the matrix-vector equivalent of the dot product this last equation becomes
$ - (q ^T U)^2 = a^4 - a^2 (q^T q) - a^2 (U^T U) $
Re-arrange the equation
$ a^2 (q^T q) - (q^T U)^2 = a^2 (a^2 - U^T U) $
Note that $(q^T U)^2 = (q^T U) (q^T U) = (q^T U)(U^T q) = q^T (U U^T) q $
Therefore, our equation becomes
$ q^T ( a^2 I - U U^T ) q = a^2 (a^2 - U^T U ) $
Replacing $q$ with $p - C$ we get
$ (p - C)^T ( a^2 I - U U^T ) (p - C) = a^2 (a^2 - U^T U ) $
And this the equation of the desired locus of points, which is an ellipsoid of revolution. Recall that we defined the focal distance as
$ c = \dfrac{1}{2} \| F_2 - F_1 \| = \| U \| $
Therefore,
$ (p - C)^T ( a^2 I - U U^T ) (p - C) = a^2 (a^2 - c^2 ) $
Let $b^2 = a^2 - c^2 $, then
$ (p - C)^T ( a^2 I - U U^T ) (p - C) = a^2 b^2 $
The unit eigenvectors of $U U^T $ are
$ X_1 = \dfrac{1}{c} U$, because
$ U U^T X_1 = \dfrac{1}{c} U (c^2) = c U = c^2 X_1 $
So the corresponding eigenvalue is $c^2$
And the other two eigenvectors of $U U^T$ are any two unit vectors that are orthogonal to $X_1$, i.e. to $U$, with eigenvalues of $0$.
Therefore, the eigenvalues of $ (a^2 I - U U^T ) $ are $(a^2 - c^2), a^2, a^2$, that is, $b^2 , a^2, a^2$
Remember the right hand side of the equation is $a^2 b^2$, so dividing by this scalar, scales the eigenvalues by $ \left(\dfrac{1}{a^2 b^2}\right) $
So that the eigenvalues of
$Q = \dfrac{a^2 I - U U^T} { a^2 b^2 } $ are $\dfrac{1}{a^2}, \dfrac{1}{b^2}, \dfrac{1}{b^2} $
And our final form of the equation of this ellipsoid becomes
$ ( p - C )^T Q ( p - C) = 1 $
And as we have demonstrated, it is an ellipsoid of revolution with semi-minor axis lengths of $b$ and semi-major axis length $a$. The major axis is along the vector $U$.