title: Spherical mapping calculation (UV) for point given on sphere - strange U values
body: <p>I want to write an spherical mapping for my ray-tracer to generate UV-coordinates for the sphere. The texture applied with that mapping should looks like that:
  <a href="https://i.stack.imgur.com/Yq665.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yq665.png" alt="enter image description here"></a></p>
  
  <p>I have the sphere that is located at <code>[0.0f,0.0f,0.0f]</code> with the <code>radius</code> of <code>20.0f</code>.</p>
  
  <p>For given <code>xyz</code> point on sphere's surface (position where ray from ray-tracer hit the sphere) I calculate the <code>uv</code> coordinates with <a href="https://en.wikipedia.org/wiki/UV_mapping" rel="nofollow noreferrer">this formula</a>:</p>
  
  <pre><code>float u = 0.5f + atan2(point.getX(), point.getZ()) / (2 * PI);
  float v = 0.5f - asin(point.getY() / radius) / PI;
  </code></pre>
  
  <p>I decided to output <code>u</code> and <code>v</code> values to test the mapping.</p>
  
  <p>As for <code>v</code> it looks quite ok (values from one pole to another, from <code>0.0f</code> to <code>1.0f</code>):
  <a href="https://i.stack.imgur.com/yjvYx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yjvYx.jpg" alt="enter image description here"></a></p>
  
  <p>But the <code>u</code> does not look so good:
  <a href="https://i.stack.imgur.com/CT9Dy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CT9Dy.jpg" alt="enter image description here"></a>
  Shouldn't it be an sphere where color depends on XZ (same for all points on the same longitude, gradually changing from one longitude to another)?</p>
  
  <p>Am I wrong with interpretation of <code>point</code>, formula or something else? </p>