Recall that in producing the image onto screen, the projection window is mapped to the device window. Also, the upper-left corner of the device window has coordinates (0, 0) and corresponds to the point (left, top) in the projection window. Also, the lower-right corner of the device window (width, height) corresponds to (left+width, bottom) in the projection window. Since the mapping is a linear function for each coordinate x and y, the mapping for the y coordinate is
f(y) = (deviceWindow.height / -projectionWindow.height) 
           * (y - projectionWindow.top)
where y is the y-ccordinate of a point in the projection window. Solving for y in this equation gives the inverse mapping that appears here.