Beispiel #1
0
        public override bool Equals(object o)
        {
            if ((null == o) || !(o is Rect3F))
            {
                return(false);
            }

            Rect3F value = (Rect3F)o;

            return(Rect3F.Equals(this, value));
        }
Beispiel #2
0
        private static Rect3F CreateInfiniteRect3D()
        {
            Rect3F infinite = new Rect3F();

            infinite._x     = -float.MaxValue;
            infinite._y     = -float.MaxValue;
            infinite._z     = -float.MaxValue;
            infinite._sizeX = float.MaxValue;
            infinite._sizeY = float.MaxValue;
            infinite._sizeZ = float.MaxValue;
            return(infinite);
        }
Beispiel #3
0
        private static Rect3F CreateEmptyRect3D()
        {
            Rect3F empty = new Rect3F();

            empty._x = Float.PositiveInfinity;
            empty._y = Float.PositiveInfinity;
            empty._z = Float.PositiveInfinity;
            // Can't use setters because they throw on negative values
            empty._sizeX = Float.NegativeInfinity;
            empty._sizeY = Float.NegativeInfinity;
            empty._sizeZ = Float.NegativeInfinity;
            return(empty);
        }
Beispiel #4
0
        public bool IntersectsWith(Rect3F rect)
        {
            if (IsEmpty || rect.IsEmpty)
            {
                return(false);
            }

            return((rect._x <= (_x + _sizeX)) &&
                   ((rect._x + rect._sizeX) >= _x) &&
                   (rect._y <= (_y + _sizeY)) &&
                   ((rect._y + rect._sizeY) >= _y) &&
                   (rect._z <= (_z + _sizeZ)) &&
                   ((rect._z + rect._sizeZ) >= _z));
        }
Beispiel #5
0
        public bool Contains(Rect3F rect)
        {
            if (IsEmpty || rect.IsEmpty)
            {
                return(false);
            }

            return(_x <= rect._x &&
                   _y <= rect._y &&
                   _z <= rect._z &&
                   _x + _sizeX >= rect._x + rect._sizeX &&
                   _y + _sizeY >= rect._y + rect._sizeY &&
                   _z + _sizeZ >= rect._z + rect._sizeZ);
        }
Beispiel #6
0
 public static bool Equals(Rect3F rect1, Rect3F rect2)
 {
     if (rect1.IsEmpty)
     {
         return(rect2.IsEmpty);
     }
     else
     {
         return(rect1.X.Equals(rect2.X) &&
                rect1.Y.Equals(rect2.Y) &&
                rect1.Z.Equals(rect2.Z) &&
                rect1.SizeX.Equals(rect2.SizeX) &&
                rect1.SizeY.Equals(rect2.SizeY) &&
                rect1.SizeZ.Equals(rect2.SizeZ));
     }
 }
Beispiel #7
0
 public void Union(Rect3F rect)
 {
     if (IsEmpty)
     {
         this = rect;
     }
     else if (!rect.IsEmpty)
     {
         Float x = Math.Min(_x, rect._x);
         Float y = Math.Min(_y, rect._y);
         Float z = Math.Min(_z, rect._z);
         _sizeX = Math.Max(_x + _sizeX, rect._x + rect._sizeX) - x;
         _sizeY = Math.Max(_y + _sizeY, rect._y + rect._sizeY) - y;
         _sizeZ = Math.Max(_z + _sizeZ, rect._z + rect._sizeZ) - z;
         _x     = x;
         _y     = y;
         _z     = z;
     }
 }
Beispiel #8
0
        public void Intersect(Rect3F rect)
        {
            if (IsEmpty || rect.IsEmpty || !this.IntersectsWith(rect))
            {
                this = Empty;
            }
            else
            {
                Float x = Math.Max(_x, rect._x);
                Float y = Math.Max(_y, rect._y);
                Float z = Math.Max(_z, rect._z);
                _sizeX = Math.Min(_x + _sizeX, rect._x + rect._sizeX) - x;
                _sizeY = Math.Min(_y + _sizeY, rect._y + rect._sizeY) - y;
                _sizeZ = Math.Min(_z + _sizeZ, rect._z + rect._sizeZ) - z;

                _x = x;
                _y = y;
                _z = z;
            }
        }
Beispiel #9
0
 public bool Equals(Rect3F value)
 {
     return(Rect3F.Equals(this, value));
 }
Beispiel #10
0
 public static Rect3F Offset(Rect3F rect, Float offsetX, Float offsetY, Float offsetZ)
 {
     rect.Offset(offsetX, offsetY, offsetZ);
     return(rect);
 }
Beispiel #11
0
 public static Rect3F Offset(Rect3F rect, Vector3F offsetVector)
 {
     rect.Offset(offsetVector._x, offsetVector._y, offsetVector._z);
     return(rect);
 }
Beispiel #12
0
 public static Rect3F Union(Rect3F rect, Point3F point)
 {
     rect.Union(new Rect3F(point, point));
     return(rect);
 }
Beispiel #13
0
 public static Rect3F Union(Rect3F rect1, Rect3F rect2)
 {
     rect1.Union(rect2);
     return(rect1);
 }
Beispiel #14
0
 public static Rect3F Intersect(Rect3F rect1, Rect3F rect2)
 {
     rect1.Intersect(rect2);
     return(rect1);
 }