Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have an existing class which transforms 3D vectors and projects them on a 2D plane (Camera). The code is all written in C without help from an external library.

To project a single vector (X,Y,Z) on the screen, the code first applies the View matrix of the camera and then for the actual projection does the following:

ScreenX=X/Z;
ScreenY=Y/Z;

ScreenX and ScreenY are then used as the screen coordinates (after additional scaling and translation).

What kind of projection is this?

Since it uses the Z coordinate to adjust the X and Y coordinates, I would think it is a perspective projection, but I'm not sure. If it's indeed a perspectice projection, then what would be the FOV for this?

I'm just trying to understand how the existing code works so that I can rebuild it using standard libraries and using a standard projection matrix if possible.

Any idea?

Edit - Some more information:

After this division, the coordinates are multiplied (scaled) by the "lens resolution" (pixels per unit) and translated by the lens center (X,Y coordinates in pixels):

ScreenX = ScreenX * Res + CenterX;
ScreenY = ScreenY * Res + CenterY;

Res is a large number and I'm guessing it defines the projection plane, letting the coordinates scale from 0 to the size of the actual image in pixels.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

After some more research I found out it's a Pinhole Camera Model. It is supposed to model a real camera.

There is a nice description here: http://www.epixea.com/research/multi-view-coding-thesisse8.html

What I was having trouble understanding was that I need some sort of projection plane. If there is no projection plane, all pixels would basically meet in the same singular point and would have the same coordinates. This is basically the same as the Near Plane in a perspective projection. It is a very small value, but it can't be zero.

There is no Far-Plane, since in a real camera there is no clipping of far objects. Just like in a real camera this means that you don't have a Z (depth) value that you can use.

share|improve this answer

It is a perspective projection, but those elements alone do not define the field of view.

This article covers more of the basics of the components of a projection. http://msdn.microsoft.com/en-us/library/aa916436.aspx

share|improve this answer
    
I think they do define a FOV of atan(1/1) * 2 = 90°. –  msell Apr 26 '13 at 18:03
    
@msell sure, they might have a hidden unity in there. I would look for the FOV in that view matrix first. –  Seth Battin Apr 26 '13 at 18:42
    
I should mention that the View matrix I have represents a real camera, not a virtual one. So I'm not sure how the concepts of a near and far plane apply to this. They would be 0 and infinity. Besides, the existing code works, I just don't know why... –  aKzenT Apr 26 '13 at 20:14
    
The View Matrix I calculate myself from the known world coordinates and rotation in space. So no hidden FOV there.. –  aKzenT Apr 26 '13 at 20:16
    
Please see my edit. I think maybe I found the missing "plane" hidden in another parameter. What do you think? –  aKzenT Apr 26 '13 at 20:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.