Sign in to follow this  
darkhack_83

Orbit Camera

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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this