Code

fix bug #1752969 division by zero in fractalize
authorpopolon2 <popolon2@users.sourceforge.net>
Thu, 12 Jul 2007 22:42:04 +0000 (22:42 +0000)
committerpopolon2 <popolon2@users.sourceforge.net>
Thu, 12 Jul 2007 22:42:04 +0000 (22:42 +0000)
share/extensions/fractalize.py

index 8ec9f80aed078f14c255d9052165045c126056f8..e0611d75cd25271a701c3159d969ddec500039fd 100755 (executable)
@@ -27,8 +27,12 @@ def calculateSubdivision(x1,y1,x2,y2,smoothness):
     hy = y1 + y3/2\r
     """ Calculate normalized vector perpendicular to the vector (x3,y3) """\r
     length = math.sqrt(x3*x3 + y3*y3)\r
-    nx = -y3/length\r
-    ny = x3/length\r
+    if length != 0:\r
+      nx = -y3/length\r
+      ny = x3/length\r
+    else:\r
+      nx = 1\r
+      ny = 0\r
     """ Scale perpendicular vector by random factor """\r
     r = random.uniform(-length/(1+smoothness),length/(1+smoothness))\r
     nx = nx * r\r