geometry.py

changeset 147
bec55b021ae7
parent 103
662de6b8cfc2
--- a/geometry.py	Thu Aug 26 19:16:25 2021 +0300
+++ b/geometry.py	Thu Aug 26 19:36:44 2021 +0300
@@ -195,20 +195,16 @@
     def perimeter_lines(self):
         for v1, v2 in pairs(self.vertices):
             yield LineSegment(v1, v2)
-    @property
-    def angles(self):
-        from math import acos, isclose
+    def angle_cosines(self):
+        from math import isclose
         for v1, v2, v3 in pairs(self.vertices, count = 3):
             vec1 = (position_vector(v3) - position_vector(v2)).normalized()
             vec2 = (position_vector(v1) - position_vector(v2)).normalized()
             if not isclose(vec1.length(), 0) and not isclose(vec2.length(), 0):
                 cosine = dot_product(vec1, vec2) / vec1.length() / vec2.length()
-                yield acos(cosine)
-    @property
-    def smallest_angle(self):
-        return min(
-            angle_magnitude_key(angle)
-            for angle in self.angles)
+                yield cosine
+            else:
+                yield 1 # cos(0)
     @property
     def hairline_ratio(self):
         lengths = [line.length for line in self.perimeter_lines]

mercurial