Johnny Pauling
Johnny Pauling

Reputation: 13387

Perspective projection - how to convert coordinates

I'm studying perspective projections and I stumbled upon this concept: enter image description here

Basically it says that if I have a point (x,y,z) I can project it into my perspective screen (camera space) by doing

x' = x/z
y' = y/z
z' = f(z-n) / z(f-n)

I can't understand why x' = x/z or y' = y/z

Upvotes: 1

Views: 960

Answers (3)

Nivesh Gadipudi
Nivesh Gadipudi

Reputation: 506

Homogenous coordinates give us the power to represent a point/line at infinity. we add 1 to the vector representation. The more the distance of a point in 3d space, It tends to move toward the optical centre. cartesian to homogenous p=(x,y)to(x,y,1) homogenous to cartesian (X, Y, Z)to(X/Z, Y/Z) For instance, 1. you are travelling in an aeroplane and when you look down, it doesn't seem like points move faster from one instant to another. This is distance is very large, Distance =1/Disparity(drift of the same point in two frames). 2. Try with substituting Infinity in the disparity, it means distance is 0.

Upvotes: 0

comingstorm
comingstorm

Reputation: 26087

Geometrically, it is a matter of similar triangles.

In your diagram, because (x,y,x) is on the same dotted line as (x',y',z'):

triangle [(0,0,0), (0,0,z), (x,y,z)]
  is similar to
triangle [(0,0,0), (0,0,z'), (x',y',z')]

This means that the corresponding sides have a fixed ratio. And, further, the original vector is proportional to the projected vector. Finally, note that the notional projection plane is at z' = 1:

(x,y,z) / z   =  (x',y',z') / z'

  -> so, since z' = 1:
       x'/z' = x' = x/z
       y'/z' = y' = y/z

[Warning: note that the z' in my answer is different from its occurrence in the question. The question's z' = f(z-n) / z(f-n) doesn't correspond directly to a physical point: it is a "depth value", which is used to do things like hidden surface removal.]

Upvotes: 1

JasonD
JasonD

Reputation: 16582

One way to look at this, is that what you are trying to do, is intersect a line which passes through both the viewer position (assumed to be at the origin: 0,0,0), and the point in space you wish to project (P).

So you take the equation of the line, which is P' = P * a, where a is simply a scalar value and solve for P'.Z = 1 (which is where your projection plane is). This is trivially true when the scalar multiple is 1 / P.Z, so the projected point is (P.X, P.Y, P.Z) * (1 / P.Z)

Upvotes: 1

Related Questions