Ejemplo n.º 1
0
def main():
    circ1 = Circle(Point(2, 2),'black',500)
    circ2 = Circle(Point(2, 2),'black',500)
    circ3 = Circle(Point(2, 2),'black',600)
    circ4 = Circle(Point(1, 2),'black',500)

    print(circ1==circ2)
    print(circ2==circ3)
    print(circ2==circ4)
    print(circ3==circ4)
    print(circ4==circ4)
Ejemplo n.º 2
0
 def __init__(self,
              originPoint=Point(0, 0),
              colour='black',
              width=1000,
              height=1000):
     self.__originPoint = originPoint
     self.__colour = colour
     self.__width = width
     self.__height = height
     self.__centerPoint = Point(
         self.__originPoint.getX() + self.__width / 2,
         self.__originPoint.getY() + self.__height / 2)
     self.__finalDiagonalPoint = Point(
         self.__originPoint.getX() + self.__width,
         self.__originPoint.getY() + self.__height)
     self.__finalBasePoint = Point(self.__originPoint.getX() + self.__width,
                                   self.__originPoint.getY() + 0)
     self.__diagonalLine = Line(self.__originPoint,
                                self.__finalDiagonalPoint)
     self.__baseLine = Line(self.__originPoint, self.__finalBasePoint)
Ejemplo n.º 3
0
def main():
    rec1 = Rectangle(Point(2, 2), 'black', 500, 500)
    rec2 = Rectangle(Point(2, 2), 'black', 500, 500)
    rec3 = Rectangle(Point(2, 2), 'black', 600, 500)
    rec4 = Rectangle(Point(1, 2), 'black', 500, 500)

    print(rec1 == rec2)
    print(rec2 == rec3)
    print(rec2 == rec4)
    print(rec3 == rec4)
    print(rec4 == rec4)

    print(rec1.getArea())
    print(rec1.getOriginPoint())
    print(rec1.getCenterPoint())
    print(rec1.getFinalDiagonalPoint())

    rec1.move(Point(4, 4))
    print(rec1.getArea())
    print(rec1.getCenterPoint())
    print(rec1.getDiagonalLine())
    rec1.scale(2.0)
    print(rec1.getCenterPoint())
    print(rec1.getArea())
    line1 = rec1.getDiagonalLine()
    print(line1)
    print(line1.getAngle())

    line2 = Line(Point(0, 0), Point(-2, 10))
    print('line1 Angle = ', line1.getAngle())
    print('line2 Angle = ', line2.getAngle())
    print('Angle Between Lines 1 and 2 = ', Line.getLinesAngle(line1, line2))

    rec2 = Rectangle(Point(2, 2), None, 500, 1000)
    print(rec2.getBaseLine())
    print(rec2.getBaseLine().getAngle())
    print(rec2.collides(line2))
Ejemplo n.º 4
0
 def __updateFinalDiagonalPoint(self):
     self.__finalDiagonalPoint = Point(
         self.__originPoint.getX() + self.__width,
         self.__originPoint.getY() + self.__height)
Ejemplo n.º 5
0
 def __updateFinalBasePoint(self):
     self.__finalBasePoint = Point(self.__originPoint.getX() + self.__width,
                                   self.__originPoint.getY() + 0)
Ejemplo n.º 6
0
 def __updateCenterPoint(self):
     self.__centerPoint = Point(
         self.__originPoint.getX() + self.__width / 2,
         self.__originPoint.getY() + self.__height / 2)
Ejemplo n.º 7
0
def main():
    line = Line(Point(2, 2), Point(4, 4))
    print(line.__str__())
Ejemplo n.º 8
0
class TestLineMethods(unittest.TestCase):

    line = Line(Point(2, 2), Point(1, 4))
    line2 = Line(Point(2, 2), Point(4, 4))
    line3 = Line(Point(0, 0), Point(0, 4))
    line4 = Line(Point(0, 0), Point(0, 4))
    line5 = Line(Point(0, 0), Point(0, -4))
    line6 = Line(Point(0, 0), Point(10, -4))
    line7 = Line(Point(0, 0), Point(0, 1))


    def test_slope(self):
        pass
        self.assertEqual(self.line.getSlope(), -2.0)
        self.assertEqual(self.line2.getSlope(), 1.0)
        self.assertEqual(self.line3.getSlope(), None)
        self.assertEqual(self.line4.getSlope(), None)


    def test_angle(self):

        self.assertAlmostEqual(self.line.getAngle(), 116.565,3)
        self.assertEqual(self.line2.getAngle(),45.0)
        self.assertEqual(self.line3.getAngle(), 90.0)
        self.assertEqual(self.line4.getAngle(), 90.0)
        self.assertEqual(self.line5.getAngle(), 270.0)
        self.assertAlmostEqual(self.line6.getAngle(), 338.198,2)
        self.assertEqual(self.line7.getAngle(), 90.0)