summaryrefslogtreecommitdiff
path: root/librelogo
diff options
context:
space:
mode:
authoradityasingh22 <adityasingh22011997@gmail.com>2023-03-09 16:52:52 +0530
committerIlmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>2023-03-19 18:17:46 +0000
commit1f22d01b7ae96a7efa91c9285f3d2f8c37f05237 (patch)
treed8603eb295dfbb0060aa4250b0bc34ff98e75c10 /librelogo
parentba58d80a1a9c30e58b20184135e81cc1851bdd75 (diff)
tdf#147906: Use python's math.hypot() for Pythagorean addition
Change-Id: Iff40b4fcbfd0fce492aff4f10f7651899d36872d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148547 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'librelogo')
-rw-r--r--librelogo/source/LibreLogo/LibreLogo.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py
index 1ba5b835244f..1cab5ec96cb4 100644
--- a/librelogo/source/LibreLogo/LibreLogo.py
+++ b/librelogo/source/LibreLogo/LibreLogo.py
@@ -194,7 +194,7 @@ class __Doc__:
self.fontstyle = 0
self.points = []
-from math import pi, sin, cos, asin, sqrt, log10
+from math import pi, sin, cos, asin, log10, hypot
from com.sun.star.awt import Point as __Point__
from com.sun.star.awt import Gradient as __Gradient__
@@ -956,7 +956,7 @@ def heading(deg = -1, go = False):
px, py = pos.X + turtle.BoundRect.Width / 2.0, pos.Y + turtle.BoundRect.Height / 2.0
dx = px * __MM10_TO_TWIP__ - deg[0] * __PT_TO_TWIP__
dy = deg[1] * __PT_TO_TWIP__ - py * __MM10_TO_TWIP__
- n = sqrt(dx**2 + dy**2)
+ n = hypot(dx, dy)
if dy > 0 and n > 0:
turtle.RotateAngle = a = -(180 + asin(dx / n) / (pi/180)) * 100 + 72000 # +720 for max(angle, preciseAngle) of __go__()
elif n > 0: