Esempio n. 1
0
 /// <summary>
 /// Writes the given <see cref="Boxd"/> to an <see cref="Ibasa.IO.BinaryWriter">.
 /// </summary>
 public static void Write(this Ibasa.IO.BinaryWriter writer, Boxd 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);
 }
Esempio 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, Boxd 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);
            }
        }
Esempio n. 3
0
 public static bool Contains(Boxd box, Point3d 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));
 }
Esempio 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(Boxd left, Boxd right)
 {
     return(left == right);
 }