Advertisement Jump to content
Sign in to follow this  

Rotating around an object using the camera

This topic is 3012 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


I've undestood how the frustum have to be set (, but now I have a trouble to rotate the camera on the X-axis around an object centered in (0, 0, 0).

I rotate on Y-axis modifying only the position X and Z with sin and cos.
I rotate on Z-axis modifying only the up vector X and Y params.

Initialy the camera is in position (0, 0, 2) looking to (0, 0, 0) with up vector (0, 1, 0).

If I rotate on the X-axis modifying only the Y and Z params there's a moment, when view vector (at - pos) is equal to up vector (0, 1, 0) and equal to (0, -1, 0), where the camera rotates 180º on Y-axis...

Sure this question has been answered before a lot of times...


Share this post

Link to post
Share on other sites
You want to do the transformations all together

Vector3( sin( pitch ) * sin( yaw ), cos( yaw ), cos( pitch ) * sin( yaw ) )

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!