I’m trying to display an image on a point on the screen.
I have the pitch and the yaw of the current point. All I need is to convert these values to a 2 coord points.
Here is what I’ve done so far:
double tmp_yaw = yaw - myPlayer_yaw;
double tmp_pitch = pitch - myPlayer_pitch;
if (tmp_yaw < -180D) tmp_yaw += 360D;
if (tmp_yaw > 180D) tmp_yaw -= 360D;
// X Y screen coords
int x = (tmp_yaw / 180) * (screen_width / 2);
int y = (tmp_pitch / 90) * (screen_height / 2);
At first glance, this code looks easy but I don’t know why I doesn’t display the point where it is expected.
Variables yaw and pitch are here the rotation to the point in 3D.
Variables myPlayer_yaw and myPlayer_pitch stand for where the player is looking at any moment.
Did I do something wrong?

I want to get those kind of results:
- I’m looking a player => Returns (height/2, width/2)
- The player is behind me => Returns (height, width/2)
- The player is on my left => Returns (height/2, 0)
- The player is on my right => Returns (height/2, width)
- The player is just above me => Returns (0, width/2)
Finally I solved it using
vertex3DHere is the code:
You can use it like that:
I hope this will help someone.