title: Mapping A Sphere To A Cube
body: <p>There is a special way of mapping a cube to a sphere described here:
  <a href="http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html" rel="noreferrer">http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html</a></p>
  
  <p>It is not your basic "normalize the point and you're done" approach and gives a much more evenly spaced mapping.</p>
  
  <p>I've tried to do the inverse of the mapping going from sphere coords to cube coords and have been unable to come up the working equations.  It's a rather complex system of equations with lots of square roots.</p>
  
  <p>Any math geniuses want to take a crack at it?</p>
  
  <p>Here's the equations in c++ code:</p>
  
  <pre><code>sx = x * sqrtf(1.0f - y * y * 0.5f - z * z * 0.5f + y * y * z * z / 3.0f);
  
  sy = y * sqrtf(1.0f - z * z * 0.5f - x * x * 0.5f + z * z * x * x / 3.0f);
  
  sz = z * sqrtf(1.0f - x * x * 0.5f - y * y * 0.5f + x * x * y * y / 3.0f);
  </code></pre>
  
  <p>sx,sy,sz are the sphere coords and x,y,z are the cube coords.</p>