Here's (an image of) a page showing how to find z for a 3D triangle, given the x,y position at which a pixel is to be plotted:
Go to CSG140 home page. or RPF's Teaching Gateway or homepage