Sign in to follow this  
Crazyfool

Camera Rotation

Recommended Posts

Howdy again folks. I got directx running and the camera functioning and now I'm just trying to make the camera rotate smoother. I starting off doin simple controls like move left, move right, up , down , forward and backward, but I thought most fun controls are in circle rotations. So I remember tthat a point on a circle is given by: Note: I use Z instead of Y because of thinking of top down circle x position = cos(angle) * radius z position = sin(angle) * radius And I used a fixed radius, and it worked surprisingly smooth. Now, I also used a fixed angle, meaning it started at 0, and each "turn" incremeted or decremented by 0.1, and again, it worked very smooth. My problem came from wanting to update the radius as I did other functions such as moving camera forward, backward, left or right (up/down dont affect it since I'm concerning myself with x and z right now). Actually, that part seems right because I do: radius = sqrt((posX - lookX)*(posX - lookX) + (posZ - lookZ)*(posZ - lookZ)); But I realized if I did those other functions (right/left/forward/back) the angle could change, but I didnt change the angle. So now I'm stuck on figuring out how to find the angle in a circle givin the radius and the coordinates of the angle side's interception with the circle. I USED to be so keen at math, but it seems I have forgot some basics (and couldnt find what I was looking for from Google). Any ideas? Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by Crazyfool
So now I'm stuck on figuring out how to find the angle in a circle givin the radius and the coordinates of the angle side's interception with the circle.


atan2 can be used to compute the angle between two points (your centre and your intersection). There's a pretty good article here that gives examples.

Sorry if that was not what you were asking. I wasn't too sure.

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