Circling an object

hi, when i press the left arrow, i wish my camera to circle the camera-target. can someone please tell me how this is done?
[123 byte] By [Prodigy074] at [2007-12-23]
# 1
oh and im using c#
Prodigy074 at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 2
Hi,

a way to do this could be the following: transform your camera position in spherical coordinates (http://mathworld.wolfram.com/SphericalCoordinates.html) and perform the rotation easily in this space. Then you can go back to cartesian coordinates.

Another way is the following: build a matrix that align your up vector to z axis and then perform the rotation of the camera position around the camera target in the XY plane (very easy to do) and then use the inverse of the computed matrix to return to the original space.

- AGPX

AGPX at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 3
You need to change the view transform. You can create a suitable one using lookatLH which allows you to pass in the camera position and the look at position. Look at position will be the location of the object you wish to circle. Camera position will be based on an angle (you will increment this angle as the arrow key is held down) and a distance from the object you are looking at. Its simple trig/dot products. If you can't do the math to work this out then I would suggest getting a simple trig book or spending some time on mathworld.com - the math only gets harder from this point on with 3d games.
TheZMan at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...