budipro 122 Report post Posted April 21, 2004 Hi all, I have two vectors: the direction vector (vector from eye point to lookat point), and vector from eye point to a point on the leftmost of the screen. How to calculate the angle between them? Is a camera field of view angle covers the width or the height of the screen? Cause a monitor''s width is longer than its height. Thanks very much. 0 Share this post Link to post Share on other sites

McGuireV10 122 Report post Posted April 21, 2004 I wrote this C# function to find the axis-angle matrix between two vectors. You can just use the angle part if that''s all you need, and you can probably adapt it to any language without much effort.public Matrix AxisAngle(Vector3 v1, Vector3 v2){ Vector3 nv1 = Vector3.Normalize(v1); Vector3 nv2 = Vector3.Normalize(v2); float angle = (float)System.Math.Acos((double)Vector3.Dot(nv1,nv2)); Vector3 axis = Vector3.Normalize(Vector3.Cross(nv1,nv2)); return Matrix.RotationAxis(axis, angle);} 0 Share this post Link to post Share on other sites

budipro 122 Report post Posted April 22, 2004 thanks for your reply.Sorry, I didn''t put my question correctly. I already know how to calculate the angle between two vectors.All I want to ask now is how to find the vector from the eye point to a point on the leftmost of the screen.I had tried to Unproject the point (0, viewport.width / 2, 1), into world space. Then I subtract this point with my eye point to get the vector. But the result is not quite right, cause the angle is changing all the time, which I think it should be always the same.Is my way to calculate the angle correct? Or is my vector calculation correct? 0 Share this post Link to post Share on other sites

Guest Anonymous Poster Report post Posted April 22, 2004 There''s actually an infinite number of 3d positions belonging to the 2d left border of the screen... They all belong to your frustrum''s left plane. Now, if you want the leftmost points on screen aligned on the horizon then they all belong to the line parralel to the above plane and going trough the eye position. I think what you are looking for is more like a definition of fov. X /|s p ^ / |c l | / |r aeye->Z|e n \ |e e \ |n . \|z = zoomUsually the left plane of your frustrum (left border of the screen) intersect the screen plane (Z=zoom) at coordinate X=-1.Given this property and provided you build your frustrum this wayone of the points you are looking for would be (-1,0,zoom) in camera space.I hope you can derive useful stuff from that...Of course the upper and bottom plane intersect on coordinate Y=aspect_ratio of display (ie: height/width), so yes, usually the fov covers the width of the screen but nothing force you to do it that way. 0 Share this post Link to post Share on other sites