Fix perspective matrix calculation.

Backported from ruby-snowmath because I'm an idiot.