-
July 18th, 2012, 07:05 AM
#1
Spherical coordinates to XYZ?
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!
-
July 19th, 2012, 10:00 AM
#2
Re: Spherical coordinates to XYZ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|