Ejemplo n.º 1
0
 public Model()
 {
     WorldMouse = new Models.WorldMouse();
      BoundingBox = new BoundingBox();
      allViewPorts = new Dictionary<String, CadViewPort>();
      allGrahics = new List<Graphic>();
      NotificationTarget = null;
      FeatureList = new FeatureList();
 }
Ejemplo n.º 2
0
        public void BoundingBox_Translated_20_20Rotated45degrees_yields28_28()
        {
            var bb = new BoundingBox(-90, -10, 110, 10);
             var aspectVector = bb.getAsVectorLLtoUR();
             bb.setFrom_2dOnly(new Point(100, 0), 20, 20, Angle.AngleFactory(45.0));
             aspectVector = bb.getAsVectorLLtoUR();

             Double expectedURx = 114.142136; Double expectedURy = 14.142136;
             Double expectedLLx = 85.85786;
             Double actualURx = bb.upperRightPt.x;
             Double actualURy = bb.upperRightPt.y;
             Double actualLLx = bb.lowerLeftPt.x;

             Assert.AreEqual(expected: expectedURx, actual: actualURx, delta: 0.00001);
             Assert.AreEqual(expected: expectedLLx, actual: actualLLx, delta: 0.00001);
             Assert.AreEqual(expected: expectedURy, actual: actualURy, delta: 0.00001);
             Assert.AreEqual(expected: aspectVector.Length, actual: 40.0, delta: 0.00001);
             Assert.AreEqual(expected: aspectVector.Azimuth.getAsDegreesDouble(),
            actual: 45.0, delta: 0.00001);
        }
Ejemplo n.º 3
0
 public void BoundingBox_TotallyContainsOther_returnsTrue()
 {
     var bbBigUn = new BoundingBox(100, 100, 500, 500);
      var bbLittleUn = new BoundingBox(150, 150, 250, 250);
      Assert.AreEqual(expected: true,
     actual: bbBigUn.overlapsWith(bbLittleUn));
      Assert.AreEqual(expected: true,
     actual: bbLittleUn.overlapsWith(bbBigUn));
 }
Ejemplo n.º 4
0
 public void BoundingBox_OverlapsOther_Partial_returnsTrue()
 {
     var bbLeftLow = new BoundingBox(100, 100, 200, 200);
      var bbRightHigh = new BoundingBox(150, 150, 250, 250);
      Assert.AreEqual(expected: true,
     actual: bbLeftLow.overlapsWith(bbRightHigh));
      Assert.AreEqual(expected: true,
     actual: bbRightHigh.overlapsWith(bbLeftLow));
 }
Ejemplo n.º 5
0
 public void BoundingBox_NoOverlapOther_returnsFalse_case2()
 {
     var bbLeftLow = new BoundingBox(151, 151, 250, 250);
      var bbRightHigh = new BoundingBox(251, 51, 350, 150);
      Assert.AreEqual(expected: false,
     actual: bbLeftLow.overlapsWith(bbRightHigh));
      Assert.AreEqual(expected: false,
     actual: bbRightHigh.overlapsWith(bbLeftLow));
 }
Ejemplo n.º 6
0
 public void BoundingBox_CenterPoint_returnCorrectValue()
 {
     var aBB = new BoundingBox(-100, -100, 100, 100);
      Assert.AreEqual(expected: 0.0, actual: aBB.centerPt.x, delta: 0.000001);
      Assert.AreEqual(expected: 0.0, actual: aBB.centerPt.y, delta: 0.000001);
 }
Ejemplo n.º 7
0
        public bool overlapsWith(BoundingBox other)
        {
            return !dontOverlap(other);
             //var MaxUR = Math.Max(this.upperRightPt.x, other.upperRightPt.x);
             //var MinLL = Math.Min(this.lowerLeftPt.x, other.lowerLeftPt.x);
             //if (Math.Abs(MaxUR - MinLL) < 0.00001)
             //   return false;

             //MaxUR = Math.Max(this.upperRightPt.y, other.upperRightPt.y);
             //MinLL = Math.Min(this.lowerLeftPt.y, other.lowerLeftPt.y);
             //if (Math.Abs(MaxUR - MinLL) < 0.00001)
             //   return false;

             //return true;
        }
Ejemplo n.º 8
0
        public void expandByBox(BoundingBox other)
        {
            if (this.isInitialized == false)
             {
            lowerLeftPt = new Point(other.lowerLeftPt.x, other.lowerLeftPt.y, other.lowerLeftPt.z);
            upperRightPt = new Point(other.upperRightPt.x, other.upperRightPt.y, other.upperRightPt.z);
            this.isInitialized = true;
             }
             else
             {
            if (other.lowerLeftPt.x < lowerLeftPt.x)
               lowerLeftPt.x = other.lowerLeftPt.x;
            if (other.lowerLeftPt.y < lowerLeftPt.y)
               lowerLeftPt.y = other.lowerLeftPt.y;
            if (other.lowerLeftPt.z < lowerLeftPt.z)
               lowerLeftPt.z = other.lowerLeftPt.z;

            if (other.upperRightPt.x > upperRightPt.x)
               upperRightPt.x = other.upperRightPt.x;
            if (other.upperRightPt.y > upperRightPt.y)
               upperRightPt.y = other.upperRightPt.y;
            if (other.upperRightPt.z > upperRightPt.z)
               upperRightPt.z = other.upperRightPt.z;
             }
        }
Ejemplo n.º 9
0
 public bool dontOverlap(BoundingBox other)
 {
     // adapted from http://gamedev.stackexchange.com/questions/586/what-is-the-fastest-way-to-work-out-2d-bounding-box-intersection  answer by Wallacoloo
      bool dontOverlap = other.Left > this.Right;
      dontOverlap |= other.Right < this.Left;
      dontOverlap |= other.Top < this.Bottom;
      dontOverlap |= other.Bottom > this.Top;
      return dontOverlap;
 }