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): |