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); }
public static Normal3D Max(Normal3D a, Normal3D b) { return(new Normal3D(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y), Math.Max(a.Z, b.Z))); }
public Normal3D FaceForward(Normal3D n2) { return((Dot(n2) < 0.0) ? -this : this); }
public double AbsDot(Normal3D b) { return(Math.Abs(Dot(b))); }
public double Dot(Normal3D b) { return(X * b.X + Y * b.Y + Z * b.Z); }
public Normal3D AddScaled(Normal3D b, double scale) { return(new Normal3D(X + scale * b.X, Y + scale * b.Y, Z + scale * b.Z)); }
public Vector3D FaceForward(Normal3D n) { return((Dot(n) < 0.0) ? -this : this); }
public Vector3D Cross(Normal3D b) { return(new Vector3D(Y * b.Z - Z * b.Y, Z * b.X - X * b.Z, X * b.Y - Y * b.X)); }