def setUp(self): self.C0 = circles.Circle() self.C0prim = circles.Circle() self.C112 = circles.Circle(1, 1, 2) self.p00 = Points.Point(0, 0) self.p11 = Points.Point(1, 1)
def setUp(self): self.point0 = Points.Point(0, 0) self.point1 = Points.Point(1, 1) self.point1bis = Points.Point(1, 1) self.point2 = Points.Point(1, 2)
def test_sub(self): self.assertEqual(self.point1 - self.point2, Points.Point(0, -1))
def test_add(self): self.assertEqual(self.point1 + self.point2, Points.Point(2, 3))
def test_move(self): self.C0.move(1, 1) self.assertEqual(self.C0.pt, Points.Point(1, 1)) self.C0.move(1, -1) self.assertEqual(self.C0.pt, Points.Point(2, 0))
# pointexample.py # Bill Kronholm # 2015 # # Basic usage of the Points.py class, methods, and functions. # import Points P = Points.Point() Q = Points.Point(2, 3) print "P has coordinates (%g, %g)" %(P.x, P.y) print "Q has coordinates (%g, %g)" %(Q.x, Q.y) R = Points.Point(-4, 2) d = Points.distance(Q,R) print "Q and R are distance %g apart" % d print "R has magnitude %g" % R.magnitude() S = Points.add(Q,R) print "Q+R = S = (%g, %g)" % (S.x, S.y) print Points.subtract(Q, S)