Game - Convert pitch and yaw to XY
<p>I'm trying to display an image on a point on the screen.</p>

<p>I have the pitch and the yaw of the current point. All I need is to convert these values to a 2 coord points.</p>

<p>Here is what I've done so far:</p>

<pre><code>double tmp_yaw = yaw - myPlayer_yaw;
double tmp_pitch = pitch - myPlayer_pitch;

if (tmp_yaw &lt; -180D) tmp_yaw += 360D;
if (tmp_yaw &gt; 180D) tmp_yaw -= 360D;

// X Y screen coords
int x = (tmp_yaw / 180) * (screen_width / 2);
int y = (tmp_pitch / 90) * (screen_height / 2);
</code></pre>

<p>At first glance, this code looks easy but I don't know why I doesn't display the point where it is expected.</p>

<p>Variables <code>yaw</code> and <code>pitch</code> are here the rotation to the point in 3D.</p>

<p>Variables <code>myPlayer_yaw</code> and <code>myPlayer_pitch</code> stand for where the player is looking at any moment.</p>

<p>Did I do something wrong?</p>

<p><img src="http://i.stack.imgur.com/dQtnm.jpg" alt="enter image description here"></p>

<p>I want to get those kind of results:</p>

<ul>
<li>I'm looking a player => Returns (height/2, width/2)</li>
<li>The player is behind me => Returns (height, width/2)</li>
<li>The player is on my left => Returns (height/2, 0)</li>
<li>The player is on my right => Returns (height/2, width)</li>
<li>The player is just above me => Returns (0, width/2)</li>
</ul>
