math - Formula for calculating camera x y position to force 3d point to appear in center of screen -


i need formula calculating camera x y position force given 3d point appear in center of screen. in other words, camera pans move point center, without changing fov, rotation, or z co-ordinate.

let's assume current camera position campos , direction camdir. depending on projection, there several options how view ray screen center calculated of time just:

ray(t) = campos + camdir * t 

we don't want change position's z-coordinate. calculating parameter t hit target point p quite simple (given position had correct x , y coordinates):

t = (p.z - campos.z) / camdir.z 

we can calculate current point @ screen center @ given depth by:

currentscreencenter = campos + camdir * t 

in order hit p, campos has shifted difference:

campos += (p - currentscreencenter)         = p - campos - camdir * (p.z - campos.z) / camdir.z 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -