geometry.py

changeset 3
1dc58f44d556
parent 1
5411a25cfca7
child 5
e340e35d6e4c
equal deleted inserted replaced
2:50d3086070df 3:1dc58f44d556
9 return sqrt( 9 return sqrt(
10 (self.x - other.x) ** 2 + 10 (self.x - other.x) ** 2 +
11 (self.y - other.y) ** 2 + 11 (self.y - other.y) ** 2 +
12 (self.z - other.z) ** 2 12 (self.z - other.z) ** 2
13 ) 13 )
14 @property
15 def coordinates(self):
16 return self.x, self.y, self.z
14 17
15 class LineSegment: 18 class LineSegment:
16 def __init__(self, v1, v2): 19 def __init__(self, v1, v2):
17 self.v1, self.v2 = v1, v2 20 self.v1, self.v2 = v1, v2
18 def __repr__(self): 21 def __repr__(self):
19 return str.format('LineSegment({!r}, {!r})', self.v1, self.v2) 22 return str.format('LineSegment({!r}, {!r})', self.v1, self.v2)
23 @property
24 def vertices(self):
25 return self.v1, self.v2
20 26
21 class Polygon: 27 class Polygon:
22 def __init__(self, vertices): 28 def __init__(self, vertices):
23 self.vertices = vertices 29 self.vertices = vertices
24 def __repr__(self): 30 def __repr__(self):

mercurial