Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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)));
 }
Exemplo n.º 3
0
 public Normal3D FaceForward(Normal3D n2)
 {
     return((Dot(n2) < 0.0) ? -this : this);
 }
Exemplo n.º 4
0
 public double AbsDot(Normal3D b)
 {
     return(Math.Abs(Dot(b)));
 }
Exemplo n.º 5
0
 public double Dot(Normal3D b)
 {
     return(X * b.X + Y * b.Y + Z * b.Z);
 }
Exemplo n.º 6
0
 public Normal3D AddScaled(Normal3D b, double scale)
 {
     return(new Normal3D(X + scale * b.X, Y + scale * b.Y, Z + scale * b.Z));
 }
Exemplo n.º 7
0
 public Vector3D FaceForward(Normal3D n)
 {
     return((Dot(n) < 0.0) ? -this : this);
 }
Exemplo n.º 8
0
 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));
 }