Пример #1
0
 /// <summary>
 /// Returns true if 2 boxes intersect each other with tolerance parameter.
 /// </summary>
 public bool Intersects(Box3 box, float eps)
 {
     if (Min.X - eps > box.Max.X) return false;
     if (Max.X + eps < box.Min.X) return false;
     if (Min.Y - eps > box.Max.Y) return false;
     if (Max.Y + eps < box.Min.Y) return false;
     if (Min.Z - eps > box.Max.Z) return false;
     if (Max.Z + eps < box.Min.Z) return false;
     return true;
 }
Пример #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="b"></param>
 /// <returns></returns>
 public Box3 Union(Box3 b)
 {
     return Union(this, b);
 }
Пример #3
0
 /// <summary>
 /// Returns true if 2 boxes intersect each other.
 /// </summary>
 public bool Intersects(Box3 box)
 {
     if (Min.X > box.Max.X) return false;
     if (Max.X < box.Min.X) return false;
     if (Min.Y > box.Max.Y) return false;
     if (Max.Y < box.Min.Y) return false;
     if (Min.Z > box.Max.Z) return false;
     if (Max.Z < box.Min.Z) return false;
     return true;
 }
Пример #4
0
 /// <summary>
 /// Returns true if 2 boxes intersect each other with tolerance parameter.
 /// </summary>
 public bool Intersects(Box3 box, Vector3 eps)
 {
     if (Min.X - eps.X > box.Max.X) return false;
     if (Max.X + eps.X < box.Min.X) return false;
     if (Min.Y - eps.Y > box.Max.Y) return false;
     if (Max.Y + eps.Y < box.Min.Y) return false;
     if (Min.Z - eps.Z > box.Max.Z) return false;
     if (Max.Z + eps.Z < box.Min.Z) return false;
     return true;
 }
Пример #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="b"></param>
 /// <returns></returns>
 public Box3 Intersection(Box3 b)
 {
     return Intersection(this, b);
 }
Пример #6
0
 /// <summary>
 /// Extends the box to contain the supplied box.
 /// </summary>
 public Box3 ExtendBy(Box3 box)
 {
     if (box.Min.X < Min.X) Min.X = box.Min.X;
     if (box.Max.X > Max.X) Max.X = box.Max.X;
     if (box.Min.Y < Min.Y) Min.Y = box.Min.Y;
     if (box.Max.Y > Max.Y) Max.Y = box.Max.Y;
     if (box.Min.Z < Min.Z) Min.Z = box.Min.Z;
     if (box.Max.Z > Max.Z) Max.Z = box.Max.Z;
     return this;
 }
Пример #7
0
 /// <summary>
 /// Returns true if the box completely contains the given box.
 /// </summary>
 public bool Contains(Box3 b)
 {
     return
         b.Min.X >= Min.X && b.Max.X <= Max.X &&
         b.Min.Y >= Min.Y && b.Max.Y <= Max.Y &&
         b.Min.Z >= Min.Z && b.Max.Z <= Max.Z;
 }
Пример #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static Box3 Union(Box3 a, Box3 b)
 {
     return new Box3(VectorComparisonExtensions.ComponentMin(a.Min, b.Min), VectorComparisonExtensions.ComponentMax(a.Max, b.Max));
 }
Пример #9
0
 /// <summary>
 /// Creates box from a set points which need not be Min and Max.
 /// </summary>
 /// <param name="points"></param>        
 public static Box3 FromPoints(IEnumerable<Vector3> points)
 {
     var box = new Box3();
     foreach (var p in points)
         box.ExtendBy(p);
     return box;
 }