theseabay

07-18-2012, 05:02 AM

I am starting to get grip of my game. But I need to now how to calculate x units away in the viewing direction. I have solved this by taking the coordinates from a "invisible" sphere around me. I am using this forumla:

float Radius = 5;

float theta = (xrot/180)*3.141592654f;

float phi = (yrot/180)*3.141592654f;

s_x = xpos + (Radius * sin(theta) * cos(phi));

s_y = ypos + (Radius * sin(theta) * sin(phi));

s_z = zpos + (Radius * cos(theta));

The yrot range between 0-360. The yrot is my camera rotation around me vertically.

And my xrot range between 90 - (-90).

(-90) while looking up and 90 the opposite.

What I want to do is to get xyz from yrot and xrot.

But I just cant get it right.

Can someone tell me how to do this and maybe link to a site thats explains the formula. Thanks in advance! ;)

float Radius = 5;

float theta = (xrot/180)*3.141592654f;

float phi = (yrot/180)*3.141592654f;

s_x = xpos + (Radius * sin(theta) * cos(phi));

s_y = ypos + (Radius * sin(theta) * sin(phi));

s_z = zpos + (Radius * cos(theta));

The yrot range between 0-360. The yrot is my camera rotation around me vertically.

And my xrot range between 90 - (-90).

(-90) while looking up and 90 the opposite.

What I want to do is to get xyz from yrot and xrot.

But I just cant get it right.

Can someone tell me how to do this and maybe link to a site thats explains the formula. Thanks in advance! ;)