Jump to content
  • Advertisement
Sign in to follow this  
darkhack_83

Orbit Camera

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

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!