Ejemplo n.º 1
0
        public void TestClosestPointHorizontal()
        {
            Line2 line = new Line2(new Vector2(0.0f, 100.0f), Vector2.UnitX);

            Vector2 leftCap = line.ClosestPointTo(new Vector2(-2.0f, 200.0f));

            Assert.AreEqual(new Vector2(-2.0f, 100.0f), leftCap, "Closest point beyond left end found");

            Vector2 leftPoint = line.ClosestPointTo(new Vector2(0.0f, 200.0f));

            Assert.AreEqual(new Vector2(0.0f, 100.0f), leftPoint, "Closest point on left end found");

            Vector2 midLeftRight = line.ClosestPointTo(new Vector2(0.5f, 200.0f));

            Assert.AreEqual(new Vector2(0.5f, 100.0f), midLeftRight, "Closest point inmidst of line found");

            Vector2 rightPoint = line.ClosestPointTo(new Vector2(1.0f, 200.0f));

            Assert.AreEqual(new Vector2(1.0f, 100.0f), rightPoint, "Closest point on right end found");

            Vector2 rightCap = line.ClosestPointTo(new Vector2(3.0f, 200.0f));

            Assert.AreEqual(new Vector2(3.0f, 100.0f), rightCap, "Closest point beyond right end found");
        }
Ejemplo n.º 2
0
        public void TestClosestPointVertical()
        {
            Line2 line = new Line2(new Vector2(100.0f, 0.0f), Vector2.UnitY);

            Vector2 leftCap = line.ClosestPointTo(new Vector2(200.0f, -2.0f));

            Assert.AreEqual(new Vector2(100.0f, -2.0f), leftCap, "Closest point beyond lower end found");

            Vector2 leftPoint = line.ClosestPointTo(new Vector2(200.0f, 0.0f));

            Assert.AreEqual(new Vector2(100.0f, 0.0f), leftPoint, "Closest point on lower end found");

            Vector2 midLeftRight = line.ClosestPointTo(new Vector2(200.0f, 0.5f));

            Assert.AreEqual(new Vector2(100.0f, 0.5f), midLeftRight, "Closest point inmidst of line found");

            Vector2 rightPoint = line.ClosestPointTo(new Vector2(200.0f, 1.0f));

            Assert.AreEqual(new Vector2(100.0f, 1.0f), rightPoint, "Closest point on upper end found");

            Vector2 rightCap = line.ClosestPointTo(new Vector2(200.0f, 3.0f));

            Assert.AreEqual(new Vector2(100.0f, 3.0f), rightCap, "Closest point beyond upper end found");
        }
Ejemplo n.º 3
0
    public void TestClosestPointHorizontal() {
      Line2 line = new Line2(new Vector2(0.0f, 100.0f), Vector2.UnitX);

      Vector2 leftCap = line.ClosestPointTo(new Vector2(-2.0f, 200.0f));
      Assert.AreEqual(new Vector2(-2.0f, 100.0f), leftCap, "Closest point beyond left end found");

      Vector2 leftPoint = line.ClosestPointTo(new Vector2(0.0f, 200.0f));
      Assert.AreEqual(new Vector2(0.0f, 100.0f), leftPoint, "Closest point on left end found");

      Vector2 midLeftRight = line.ClosestPointTo(new Vector2(0.5f, 200.0f));
      Assert.AreEqual(new Vector2(0.5f, 100.0f), midLeftRight, "Closest point inmidst of line found");

      Vector2 rightPoint = line.ClosestPointTo(new Vector2(1.0f, 200.0f));
      Assert.AreEqual(new Vector2(1.0f, 100.0f), rightPoint, "Closest point on right end found");

      Vector2 rightCap = line.ClosestPointTo(new Vector2(3.0f, 200.0f));
      Assert.AreEqual(new Vector2(3.0f, 100.0f), rightCap, "Closest point beyond right end found");
    }
Ejemplo n.º 4
0
    public void TestClosestPointVertical() {
      Line2 line = new Line2(new Vector2(100.0f, 0.0f), Vector2.UnitY);

      Vector2 leftCap = line.ClosestPointTo(new Vector2(200.0f, -2.0f));
      Assert.AreEqual(new Vector2(100.0f, -2.0f), leftCap, "Closest point beyond lower end found");

      Vector2 leftPoint = line.ClosestPointTo(new Vector2(200.0f, 0.0f));
      Assert.AreEqual(new Vector2(100.0f, 0.0f), leftPoint, "Closest point on lower end found");

      Vector2 midLeftRight = line.ClosestPointTo(new Vector2(200.0f, 0.5f));
      Assert.AreEqual(new Vector2(100.0f, 0.5f), midLeftRight, "Closest point inmidst of line found");

      Vector2 rightPoint = line.ClosestPointTo(new Vector2(200.0f, 1.0f));
      Assert.AreEqual(new Vector2(100.0f, 1.0f), rightPoint, "Closest point on upper end found");

      Vector2 rightCap = line.ClosestPointTo(new Vector2(200.0f, 3.0f));
      Assert.AreEqual(new Vector2(100.0f, 3.0f), rightCap, "Closest point beyond upper end found");
    }