Esempio n. 1
0
    def test_linear_coefficient(self):
        p1 = p.Point(2, 2.5)
        p2 = p.Point(4, 4)
        line = l.Line()
        line.create(p1, p2)

        assert (float(line.Linear) == (1.0))
Esempio n. 2
0
 def test_vector(self):
     a = v.Vector(3, 4)
     assert (a.i == 3 and a.j == 4)
     b = v.Vector(p.Point(3, 5))
     assert (b.i == 3 and b.j == 5)
     c = v.Vector(p.Point(7, 42), p.Point(-2, 30))
     assert (c.i == -9 and c.j == -12)
Esempio n. 3
0
    def test_b_coefficient(self):
        p1 = p.Point(2, 2.5)
        p2 = p.Point(4, 4)
        line = l.Line()
        line.create(p1, p2)

        assert (float(line.B) == 2.0)
Esempio n. 4
0
    def test_angular_coefficient(self):
        p1 = p.Point(2, 2.5)
        p2 = p.Point(4, 4)
        line = l.Line()
        line.create(p1, p2)

        assert (float(line.Angular) == (0.75))
Esempio n. 5
0
    def test_line_equation(self):
        p1 = p.Point(2, 2)
        p2 = p.Point(4, 4)
        line = l.Line()
        line.create(p1, p2)

        assert (type(line.equation()) == str)
Esempio n. 6
0
    def test_ACoefficient(self):
        p1 = p.Point(2, 2.5)
        p2 = p.Point(4, 4)
        line = l.Line()
        line.create(p1, p2)

        assert (float(line.A) == (-1.5))
Esempio n. 7
0
    def test_instance_two_points(self):
        p1 = p.Point(2, 2)
        p2 = p.Point(4, 4)
        line = l.Line()
        line.create(p1, p2)

        assert (str(line) == "-2.0x+2.0y+0=0")
Esempio n. 8
0
 def create_via_equation(self, equation):
     """
     This function is for getting a line created by a line equation
     """
     self.createdby = "equation"
     regex = re.compile(
         r'([\+\-]?\d*x)\s*([\+\-]\d*y)\s*([\+\-]\d*)\s*\=\s*([\+\-]?\d*)')
     values = regex.findall(equation)
     values = values[0]
     self.A = "+1" if values[0] == 'x' or values[
         0] == '+x' else "-1" if values[0] == '-x' else values[0][:-1]
     self.B = "+1" if values[
         1] == '+y' else "-1" if values[1] == '-y' else values[1][:-1]
     self.C = values[2]
     self.Angular = (float(self.A) / float(self.B))
     self.Angulation = degrees(atan(float(self.Angular)))
     self.PointOne = p.Point(float(self.C) / float(self.A), 0)
     self.PointTwo = p.Point(0, float(self.C) / float(self.B))
Esempio n. 9
0
    def test_instance_one_point_and_slope(self):
        p1 = p.Point(4, 4.5)
        line = l.Line()
        line.create_via_slope(p1, 1)

        assert (line.equation() == "y=1x+0.5")
Esempio n. 10
0
 def test_quadrant(self):
     assert (p.Point(2, -8).quadrant() == 4)
Esempio n. 11
0
 def test_midpoint(self):
     assert (str(p.Point(9, 8).midpoint(p.Point(1,
                                                2))) == "Point(5.0, 5.0)")
Esempio n. 12
0
 def test_equal(self):
     a = v.Vector(34, 12)
     b = v.Vector(p.Point(34, 12))
     c = v.Vector(p.Point(12, -4), p.Point(46, 8))
     assert (a.equal(b) and a.equal(c))
Esempio n. 13
0
 def test_distance(self):
     assert (p.Point(9, 8).distance(p.Point(1, 2)) == 10)