public void TestIntersectIntersect1pxLeftTooFar() { //Preconfig int radius1 = 20; Vector center1 = new Vector(0f, 0f); int radius2 = 20; Vector center2 = new Vector(-19, 0f); Vector ballSpeed = new Vector(-5, 0); Vector hitPoint; bool isIntersec = false; //Creation Bumper parent = new Bumper(); Ball ball = new Ball(); BoundingContainer bCont = new BoundingContainer(parent); BoundingContainer bCont2 = new BoundingContainer(ball); BoundingCircle bC1 = new BoundingCircle(radius1, center1); BoundingCircle bC2 = new BoundingCircle(radius2, center2); bCont.AddBoundingBox(bC1); bCont2.AddBoundingBox(bC2); ball.Velocity = ballSpeed; parent.Location = (new Vector(0, 0)); parent.Width = 2 * radius1; parent.Height = 2 * radius1; //Operation isIntersec = bC1.Intersect(bC2, out hitPoint, ballSpeed); //Assertion Assert.IsTrue(isIntersec); Assert.AreEqual(new Vector(40, 20), hitPoint); }
public void TestIntersect1pxOverlapBot() { //Preconfig Vector position1 = new Vector(0f, 50f); Vector target1 = new Vector(50f, 50f); int radius2 = 20; Vector center2 = new Vector(20, 49); Vector ballSpeed = new Vector(0, -5); Vector hitPoint; bool isIntersec = false; //Creation Line parent = new Line(); Ball ball = new Ball(); BoundingContainer bCont = new BoundingContainer(parent); BoundingContainer bCont2 = new BoundingContainer(ball); BoundingLine bL1 = new BoundingLine(position1, target1); BoundingCircle bC2 = new BoundingCircle(radius2, center2); bCont.AddBoundingBox(bL1); bCont2.AddBoundingBox(bC2); ball.Velocity = ballSpeed; parent.Location = (new Vector(0, 0)); //Operation isIntersec = bC2.Intersect(bL1, out hitPoint); //Assertion Assert.IsTrue(isIntersec); Assert.AreEqual(new Vector(40,50), hitPoint); }
public void TestIntersectIntersectNone() { //Preconfig Vector target1 = new Vector(20, 50); Vector position1 = new Vector(0f, 50f); int radius2 = 20; Vector center2 = new Vector(10, 0f); Vector ballSpeed = new Vector(0, 5); Vector hitPoint; bool isIntersec = false; //Creation Line parent = new Line(); Ball ball = new Ball(); BoundingContainer bCont = new BoundingContainer(parent); BoundingContainer bCont2 = new BoundingContainer(ball); BoundingLine bL1 = new BoundingLine(position1, target1); BoundingCircle bC2 = new BoundingCircle(radius2, center2); bCont.AddBoundingBox(bL1); bCont2.AddBoundingBox(bC2); ball.Velocity = ballSpeed; parent.Location = new Vector(0, 0); parent.Width = 20; parent.Height = 0; //Operation isIntersec = bC2.Intersect(bL1, out hitPoint); //Assertion Assert.IsFalse(isIntersec); }
public void TestIntersectNoIntersectTouch() { //Preconfig int radius1 = 20; Vector center1 = new Vector(0f, 0f); int radius2 = 20; Vector center2 = new Vector(40f, 0f); Vector ballSpeed = new Vector(-5, 0); Vector hitPoint; bool isIntersec = false; //Creation Bumper parent = new Bumper(); Ball ball = new Ball(); BoundingContainer bCont = new BoundingContainer(parent); BoundingContainer bCont2 = new BoundingContainer(ball); BoundingCircle bC1 = new BoundingCircle(radius1, center1); BoundingCircle bC2 = new BoundingCircle(radius2, center2); bCont.AddBoundingBox(bC1); bCont2.AddBoundingBox(bC2); ball.Velocity = ballSpeed; //Operation isIntersec = bC1.Intersect(bC2, out hitPoint); //Assertion Assert.IsFalse(isIntersec); }