title: Find two most distant points in a set of points in 3D space
body: <p>I need to find the diameter of the points cloud (two points with maximum distance between them) in 3-dimensional space. As a temporary solution, right now I'm just iterating through all possible pairs and comparing the distance between them, which is a very slow, <code>O(n^2)</code> solution.</p>
  
  <p>I believe it can be done in <code>O(n log n)</code>. It's a fairly easy task in 2D (just find the <strong>convex hull</strong> and then apply the <strong>rotating calipers</strong> algorithm), but in 3D I can't imagine how to use rotating calipers, since there is no way to order the points. </p>
  
  <p>Is there any simple way to do it (or ready-to-use implementation in <code>python</code> or <code>C/C++</code>)? </p>
  
  <p><strong>PS</strong>: There are similar questions on StackOverflow, but the answers that I found only refers to Rotating Calipers (or similar) algorithms, which works fine in 2D situation but not really clear how to implement in 3D (or higher dimensionals). </p>