Sei sulla pagina 1di 2

Example of Perspective Transformation

Required projection: Translate the unit cube by (0, m, n), rotate about the y-axis,
view from position d on the z-axis and project onto the z = 0 plane.

1 0 0 0  cosθ 0 sin θ 0  1 0 0 0   cosθ 0 sin θ nsinθ 


0 0  0  
 1 0
 1 0 0 0 1 0 m  0 1 0 m 
0 0 − sin θ =
0 0 0 cosθ 0  0 0 1 n  0 0 0 0 
 1 
1  0    sin θ cosθ ncosθ 
0 0 0 0 1  − 0 1+
d 
0 0 1  0
 d   d d

Note that the 3rd row is all 0, since projection is onto the z = 0 plane. Note also that 2
of the 3 perspective terms in the 4th row are non-zero indicating a two-point
perspective in x and z. Lines in y remain parallel in y after transformation.

Therefore the required transformation of each point is given by:

 cosθ 0 sin θ nsinθ  0 0 0 0 1 1 1 1


 0 
 1 0 m  0 0 1 1 0 0 1 1
 0 0 0 0  0 1 1 0 0 1 1 0
 sin θ cosθ ncosθ   
− d 0 1+
d  
1 1 1 1 1 1 1 1
 d

Now substitute for θ, m, n and d. For example, take θ = 60o , m = -2, n = 1 and d = 1.
That is we are viewing the cube from very close to it and so we can expect significant
distortion in the specified projected view.

The matrix of transformed homogeneous coordinates is then:

0.87 1.74 1.74 0.87 1.37 2.24 2.24 1.37 


 − 2 − 2 −1 −1 − 2 −2 −1 − 1 

 0 0 0 0 0 0 0 0 
 
 1.5 2 2 1.5 0.63 1.813 1.13 0.63

x 
 x′  W 
and recall that (x′ y ′ 1) = ( x y W) ie.  y ′ =  y 
 W
 1   1 
 
and therefore the projected points are:

 0.58 0.87 0.87 0.58 2.17 1.98 1.98 2.17 


− 1.33 − 1 − 0.5 − 1.33 − 3.17 − 1.77 − 0.88 − 1.59
 
Graphically:
y

vp1 vp2 x

How is it that points at infinity (vanishing points) map to finite points after a
perspective projection? The vanishing points are shown in the above example along
with artist constructors.
The vectors of points at infinity are described as follows:

x-axis: [1 0 0 0], y-axis: [0 1 0 0] and z-axis: [0 0 1 0]

The two-point perspective transformation of these points at infinity in our example is:

 0.5 0 0.87 0.87 1 0 0  0.5 0 0.87


 0 1 0 − 2  0 1 0  0 1 0 
 =
 0 0 0 0  0 0 1  0 0 0 
    
− 0.87 0 0.5 1.5  0 0 0 − 0.87 0 0.5 

Again we have to divide through by the homogeneous coordinate to ensure proper


scaling of the new projected points and we see that the y-axis point at infinity remains
at infinity in the 2D domain. However the x-axis and z-axis points map to the finite
points shown, vp1 (-0.57, 0) and vp2 (1.74, 0) respectively.

Points at infinity in one coordinate system are transformed to finite points in another
system by the use of homogeneous coordinates.

Potrebbero piacerti anche