PDA

View Full Version : Getting the pan/tilt of mouse



prisma
May 21st, 2009, 07:03 PM
Hi, I'm not very good with more advanced maths, so I have to ask this:

If I have a camera which gives out 360 degree pan (x) and tilt (y) values, and I want to get the pan and tilt values of where I have my cursor in the camera's view, how would I convert that?

More info: It's a Flash/AS3 project. The pan and tilt values are from the center of the camera view. Camera view size is 960x540.

Thanks for any input!

TOdorus
May 21st, 2009, 11:23 PM
Hi, I'm not very good with more advanced maths, so I have to ask this

Actually, this is basic trigonometry: getting the angle out of a triangle using the tangent. Take a look here, at the Overview section (http://en.wikipedia.org/wiki/Trigonometry).

Your mouse is a position C and your camera at position A. C is a point at the same height at your camera, some distance away. This is actually a constant, you define b, so you know at what distance the mouse is. To get the pan: a = Mouse.x - C.x . To get the tilt: a = Mouse.y - C.y . tan alpha = b/a.