/** * 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 gfx3DMatrix& aTransform, const gfxPoint& aPoint) { const gfxPoint3D l(0, 0, 1); gfxPoint3D l0 = gfxPoint3D(aPoint.x, aPoint.y, 0); gfxPoint3D p0 = aTransform.Transform3D(gfxPoint3D(0, 0, 0)); gfxPoint3D normal = aTransform.GetNormalVector(); gfxFloat n = normal.DotProduct(p0 - l0); gfxFloat d = normal.DotProduct(l); if (!d) { return 0; } return n/d; }