# Orbit Camera

This topic is 4900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I've found in this forum some guy that used this formula to position an orbit camera around a point. mPos.x = ORBIT_DISTANCE * sinf(mXRotation) * sinf(mYRotation); mPos.y = ORBIT_DISTANCE * cosf(mXRotation); mPos.z = ORBIT_DISTANCE * sinf(mXRotation) * cosf(mYRotation); I've tried to implement it, but I have some problems. For example: What happens if my X-Axis rotation angle is 0º?. In that situation, my camera position will be 0, but i could be rotating in Y axis... so the position should not be 0. How can i implement this orbit camera properly? Where can i find 3d trigonometry information about positioning the camera in a 3D Space using rotation angles? If anybody has some information, i will be pleased. -Germán Cáseres Argentina P.D. - Sorry about my bad English

##### Share on other sites
Hi,
Your formula should work fine for orbiting a camera. mXRotation and mYRotation are spherical coordinates and the formula converts from spherical coordinates to cartesian coordinates.
mXRotation should be in the interval [0..PI] and mYRotation in [0..2PI].

If mXRotation is 0 then mPos = (0, ORBIT_DISTANCE, 0) which is fine, since then we are at the pole of the sphere and mYRotation have any influence on the position.

Also, do you remember to convert the rotation angles from degrees to radians before passing them to sinf and cosf?

##### Share on other sites
I think my problem was that i didn't convert to radians, you're right!

Thanks!

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633721
• Total Posts
3013532
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!