finding two most distant 3d points

466 Views Asked by At

I'm trying to write an algorithm. There are $9$ points $3$ of $x$, $3$ of $y$, $3$ of $z$. How can I find the two most distant? Mathematically, I need explanation. Thank you for all appreciated answers.

Coordinates for $x$, coordinates for $y$, coordinates for $z$.

  • $1.5, 34.5, 4.4 \rightarrow $ coordinates for $x$

  • $4.5, 54.5, 7.4 \rightarrow$ coordinates for $y$

  • $6.5, 64.5, 8.4 \rightarrow $ coordinates for $z$

1

There are 1 best solutions below

0
On BEST ANSWER

you could reduce the coordinates given, by considering only the two most extreme coordinates on each axis, i.e. $x\in${1.5, 34.5}, $y\in${4.5, 54.5}, $z\in${6.5, 64.5}, this would make a total of 8 points. In general, even if you started with say 5 values at each coordinate, you could reduce to just 2 per coordinate, throwing out all but the two extreme, and you will be left with $2\times2\times2=8$ points total. They determine a rectangular parallelepiped (i.e. a rectangular box), and the longest distance is obtained when you take two "diagonally opposite" points: Pick one $x$, one $y$ and one $z$ coordinate arbitrary, form a point with these, e.g. pick the point $(1.5,4.5,64.5)$ then use the remaining coordinates to form the "opposite" point of the box, in this case $(34.5,54.5,6.5)$. The (Euclidean) distance between them is computed in the usual way, in this case $\sqrt{(34.5-1.5)^2+(54.5-4.5)^2+(6.5-64.5)^2}\approx83.38$. In general, no matter how many $x$,$y$,$z$ coordinates are given, let $dx$ be the difference between the two extreme $x$ coordinates, and similarly $dy$ be the difference between the two extreme $y$ coordinates, and $dz$ be the difference between the two extreme $z$ coordinates. Then the distance in question is $\sqrt{dx^2+dy^2+dz^2}$. This solution assumes that, as it appears from your statement, originally you combine each $x$ coordinate with each $y$ coordinate, with each $z$ coordinate to form the set of all possible points.