IntegerBoundingBox.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using DwarfCorp;
  7. namespace ABTest
  8. {
  9. public class IntegerBoundingBox
  10. {
  11. public Point3 Min;
  12. public Point3 Max;
  13. public int Width { get { return Max.X - Min.X; } }
  14. public int Height { get { return Max.Y - Min.Y; } }
  15. public int Depth { get { return Max.Z - Min.Z; } }
  16. public IntegerBoundingBox(Point3 Min, Point3 Max)
  17. {
  18. this.Min = Min;
  19. this.Max = Max;
  20. }
  21. public bool Contains(Point3 P)
  22. {
  23. return P.X >= Min.X && P.X < Max.X &&
  24. P.Y >= Min.Y && P.Y < Max.Y &&
  25. P.Z >= Min.Z && P.Z < Max.Z;
  26. }
  27. public bool Intersects(IntegerBoundingBox Other)
  28. {
  29. if (Min.X > Other.Max.X || Max.X <= Other.Min.X) return false;
  30. if (Min.Y > Other.Max.Y || Max.Y <= Other.Min.Y) return false;
  31. if (Min.Z > Other.Max.Z || Max.Z <= Other.Min.Z) return false;
  32. return true;
  33. }
  34. }
  35. }