/** * Recover the z component from a 2d transformed point by finding the intersection * of a line through the point in the z direction and the transformed plane. * * We want to solve: * * point = normal . (p0 - l0) / normal . l */ static gfxFloat RecoverZDepth(const Matrix4x4& aTransform, const gfxPoint& aPoint) { const Point3D l(0, 0, 1); Point3D l0 = Point3D(aPoint.x, aPoint.y, 0); Point3D p0 = aTransform * Point3D(0, 0, 0); Point3D normal = aTransform.GetNormalVector(); gfxFloat n = normal.DotProduct(p0 - l0); gfxFloat d = normal.DotProduct(l); if (!d) { return 0; } return n/d; }