# Rotate the camera around an Vector, how?

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

## Recommended Posts

how can i rotate the camera around an vector? i have an FPS camera and i want to add rotation not just by yaw and pitch but arround a certain object, for example i want to rotate around my Lookat vector how? i just have this formula but it only rotates the x and z position D3DXVECTOR3 vVector = m_vPos - vView; m_vPos.z = (float)(vView.z + sin(speed)*vVector.x + cos(speed)*vVector.z); m_vPos.x = (float)(vView.x + cos(speed)*vVector.x - sin(speed)*vVector.z); m_vForward = vView - m_vPos; D3DXVec3Normalize(&m_vForward,&m_vForward); pls help

##### Share on other sites
Hey,

It looks like you're on the right track, though I think you may be over complicating things.

For example, to get a bunch of points in a circle (around 0,0,0) over time you would have something like this:
float p1 = sin(cur_time) * offset;float p2 = cos(cur_time) * offset;// Note: offset is just allows you to change how far the camera is out from your target

Now you can really use p1 and p2 for anything you want: x and y, x and z, y and x, etc...

Then you just keep setting p1 and p2 as your camera's location, and set the look at vector to 0,0,0.

If you want to look somewhere else, you just add that position to p1 and p2.

As I said before that is basically what you are doing, you just need to recognize that you can use those values for Y as well.

Matt Hughson

1. 1
Rutin
49
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633410
• Total Posts
3011723
• ### Who's Online (See full list)

There are no registered users currently online

×