Example #1
0
  def test_coerce_middle_of_edge(self):
    """Tests coercion when the line intersects the middle of an edge."""
    box = self.MakeBox(0, 4, 1, 2)

    # x1 = x2
    K = numpy.matrix([[-1, 1]])
    w = 0

    assert_array_equal(polydrivetrain.CoerceGoal(box, K, w, numpy.matrix([[5], [5]])),
                       numpy.matrix([[2.0], [2.0]]))
Example #2
0
  def test_coerce_perpendicular_line(self):
    """Tests coercion when the line does not intersect and is in quadrant 2."""
    box = self.MakeBox(1, 2, 1, 2)

    # x1 = -x2
    K = numpy.matrix([[1, 1]])
    w = 0

    assert_array_equal(polydrivetrain.CoerceGoal(box, K, w, numpy.matrix([[5], [5]])),
                       numpy.matrix([[1.0], [1.0]]))
Example #3
0
  def test_coerce_outside_no_intersect(self):
    """Tests coercion when the line does not intersect the box."""
    box = self.MakeBox(3, 4, 1, 2)

    # x1 = x2
    K = numpy.matrix([[1, -1]])
    w = 0

    assert_array_equal(polydrivetrain.CoerceGoal(box, K, w, numpy.matrix([[5], [5]])),
                       numpy.matrix([[3.0], [2.0]]))
Example #4
0
    def test_coerce_inside(self):
        """Tests coercion when the point is inside the box."""
        box = self.MakeBox(1, 2, 1, 2)

        # x1 = x2
        K = numpy.matrix([[1, -1]])
        w = 0

        assert_array_equal(
            polydrivetrain.CoerceGoal(box, K, w, numpy.matrix([[1.5], [1.5]])),
            numpy.matrix([[1.5], [1.5]]))