while its a similar value to its neighbour - Z translation (and I wont say if thats above or to the left for fear of sparking a religious war!) and it only seems to change when the Z translation value changes, however the value is not quite the same
Normally I just see either this value ignored or just a 1 in all the tutorials I've seen
Can someone explain exactly what this last element does ?
Answer
The value is for Homogeneous Coordinates. Using homogeneous coordinates makes it possible to use things like quaternions and projection matrices. The last entire row is actually for dealing with homogeneous coordinates.
Essentially, the coordinates transformed by a 4x4 matrix will be a 4x1 vector, with (X,Y,Z,W) components. The final values of (X,Y,Z) are determined by taking the homogeneous coordinates and dividing them by W.
E.g. 1
[4,2,1,2] is transformed to [2,1,0.5,1]
Wherein the final XYZ coordinates are then (2,1,0.5). Again, this is useful for dealing with quaternions and creating projection matrices.
E.g 2
Projection of point p onto the plane
orthoganal to the Z axis and distance d
from the 'camera'.
.p
d | <- given
c--------|------------>Z
|
d |.p'
c--------| <- desired projection
|
p' = (d / p.z) * p
x' = dx / z
z' = d
d 0 0 0 * x = dx -> dx / z
0 d 0 0 y dy dy / z
0 0 d 0 z dz d
0 0 1 0 1 z 1
In the case of a projection matrix, homogeneous coordinates allow the projection of scene geometry onto a plane (the screen).
No comments:
Post a Comment