title: C++ Convert angles to coordinates
body: <p>I'm currently trying to convert 2 angles into x, y, z, using a formula from Matlab from Mathworks, Sph2Cart</p>
  
  <p><a href="http://www.mathworks.com/help/techdoc/ref/sph2cart.html" rel="nofollow">http://www.mathworks.com/help/techdoc/ref/sph2cart.html</a></p>
  
  <h3>Algorithm:</h3>
  
  <pre><code>x = r .* cos(elevation) .* cos(azimuth)
  y = r .* cos(elevation) .* sin(azimuth)
  z = r .* sin(elevation)
  </code></pre>
  
  <h3>In C++</h3>
  
  <pre><code>clax = 1 * cos((Altitude/360)*(2*XM_PI)) * cos((Azimuth/360)*(2*XM_PI));
  clay = 1 * sin((Altitude/360)*(2*XM_PI));
  claz = 1 * cos((Altitude/360)*(2*XM_PI)) * sin((Azimuth/360)*(2*XM_PI));
  </code></pre>
  
  <p>But no matter what Altitude and Azimuth is, clax, clay and claz is either 0 or 1.</p>
  
  <p>I'm sure that i made a mistake, and i will laugh after this how stupid i was. But really, i have no idea why this doesn't work, why the values only give 1 or 0 for each of them...</p>