Esempio n. 1
0
        public Plane(Vec3 normal, double distance)
        {
            Debug.Assert(Num.AlmostEqual(normal.Abs(), 1.0));

              this.normal = normal;
              this.distance = distance;
        }
Esempio n. 2
0
        public Ray(Vec3 origin, Vec3 dir)
        {
            Debug.Assert(Num.AlmostEqual(dir.Abs(), 1.0));

              this.origin = origin;
              this.dir = dir;
        }
Esempio n. 3
0
        /// <summary>
        /// Make a random unit vector.
        /// </summary>
        /// <remarks>
        /// Samples points in [-1, -1, -1] - [1, 1, 1] until one that's neither at
        /// the origin or outside the unit sphere is found. Returns this vector
        /// normalized to unit length.
        /// </remarks>
        public Vec3 UnitVec()
        {
            double len;
              Vec3 result;
              do
              {
            result = new Vec3(
              RandDouble(-1.0, 1.0),
              RandDouble(-1.0, 1.0),
              RandDouble(-1.0, 1.0));
            len = result.Abs();
              } while (len < Num.Epsilon || len > 1.0);

              return result.Unit();
        }