geometry.py

changeset 13
12d4ddc4bfd8
parent 12
eb74680a5e43
child 14
d383f319f35b
--- a/geometry.py	Fri Jan 19 13:41:23 2018 +0200
+++ b/geometry.py	Sun Jan 21 15:03:38 2018 +0200
@@ -67,7 +67,12 @@
     def __matmul__(self, transformation_matrix):
         return transform(self, transformation_matrix)
     def __eq__(self, other):
-        return self.coordinates == other.coordinates
+        return all(
+            abs(a - b) < 1e-8
+            for a, b in zip(self.coordinates, other.coordinates)
+        )
+    def __ne__(self, other):
+        return not self.__eq__(other)
     def __lt__(self, other):
         return self.coordinates < other.coordinates
     def __hash__(self):
@@ -146,6 +151,9 @@
     ]).determinant()
     return Vector(x, y, z).normalized()
 
+class NoIntersection(Exception):
+    pass
+
 def pairs(iterable, *, count = 2):
     '''
         Iterates the given iterable and returns tuples containing `count`

mercurial