public Point3D OffsetRayOrigin(Vector3D pError, Normal3D n, Vector3D w) { double d = n.Abs().Dot(pError); // We have tons of precision; for now bump up the offset a bunch just // to be extra sure that we start on the right side of the surface // (In case of any bugs in the epsilons code...) d *= 1024.0; Point3D offset = d * n.ToPoint3D(); if (w.Dot(n) < 0.0) { offset = -offset; } Point3D po = this + offset; // Round offset point _po_ away from _p_ for (int i = 0; i < 3; ++i) { if (offset[i] > 0.0) { po[i] = PbrtMath.NextFloatUp(po[i]); } else if (offset[i] < 0.0) { po[i] = PbrtMath.NextFloatDown(po[i]); } } return(po); }