简体   繁体   中英

Perspective projection - how to convert coordinates

I'm studying perspective projections and I stumbled upon this concept: 在此处输入图片说明

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

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 / PZ , so the projected point is (PX, PY, PZ) * (1 / PZ)

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(zn) / z(fn) doesn't correspond directly to a physical point: it is a "depth value", which is used to do things like hidden surface removal.]

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM