Exemplo n.º 1
0
 /// <summary>
 /// Writes the given <see cref="Boxi"/> to an <see cref="Ibasa.IO.BinaryWriter">.
 /// </summary>
 public static void Write(this Ibasa.IO.BinaryWriter writer, Boxi box)
 {
     writer.Write(box.X);
     writer.Write(box.Y);
     writer.Write(box.Z);
     writer.Write(box.Width);
     writer.Write(box.Height);
     writer.Write(box.Depth);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Determines whether a ray intersects the specified box.
        /// </summary>
        /// <param name="ray">The ray which will be tested for intersection.</param>
        /// <param name="box">A box that will be tested for intersection.</param>
        /// <returns>Distance at which the ray intersects the box or null if there is no intersection.</returns>
        public static double?Intersects(Rayd ray, Boxi box)
        {
            return(null);

            var  invDir = Vector.Reciprocal(ray.Direction);
            bool signX  = invDir.X < 0;
            bool signY  = invDir.Y < 0;
            bool signZ  = invDir.Z < 0;
            var  min    = signX ? box.Right : box.Left;
            var  max    = signX ? box.Left : box.Right;
            var  txmin  = (min - ray.Position.X) * invDir.X;
            var  txmax  = (max - ray.Position.X) * invDir.X;

            min = signY ? box.Top : box.Bottom;
            max = signY ? box.Bottom : box.Top;
            var tymin = (min - ray.Position.Y) * invDir.Y;
            var tymax = (max - ray.Position.Y) * invDir.Y;

            if ((txmin > tymax) || (tymin > txmax))
            {
                return(null);
            }
            if (tymin > txmin)
            {
                txmin = tymin;
            }
            if (tymax < txmax)
            {
                txmax = tymax;
            }
            min = signZ ? box.Back : box.Front;
            max = signZ ? box.Front : box.Back;
            var tzmin = (min - ray.Position.Z) * invDir.Z;
            var tzmax = (max - ray.Position.Z) * invDir.Z;

            if ((txmin > tzmax) || (tzmin > txmax))
            {
                return(null);
            }
            if (tzmin > txmin)
            {
                txmin = tzmin;
            }
            if (tzmax < txmax)
            {
                txmax = tzmax;
            }
            if (txmin < double.PositiveInfinity && txmax >= 0)
            {
                return((double)txmin);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
 public static bool Contains(Boxi box, Point3i point)
 {
     return((box.Left <= point.X) && (box.Right >= point.X) &&
            (box.Bottom <= point.Y) && (box.Top >= point.Y) &&
            (box.Front <= point.Z) && (box.Back >= point.Z));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Returns a value that indicates whether two boxes are equal.
 /// </summary>
 /// <param name="left">The first box to compare.</param>
 /// <param name="right">The second box to compare.</param>
 /// <returns>true if the left and right are equal; otherwise, false.</returns>
 public static bool Equals(Boxi left, Boxi right)
 {
     return(left == right);
 }