From 013a69d8564ebf7fdc828ae754aaaa9dc4ec0e84 Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Sun, 18 Feb 2018 21:00:40 +0100 Subject: [PATCH] Simplify theta calculation in ogl.LineShape.DrawArrow() --- wx/lib/ogl/lines.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/wx/lib/ogl/lines.py b/wx/lib/ogl/lines.py index d47dcd4d..246604ee 100644 --- a/wx/lib/ogl/lines.py +++ b/wx/lib/ogl/lines.py @@ -923,26 +923,12 @@ class LineShape(Shape): # | /(x1, y1) # |______________________ # - theta = 0.0 x1 = startPositionX y1 = startPositionY x2 = float(positionOnLineX) y2 = float(positionOnLineY) - if x1 == x2 and y1 == y2: - theta = 0.0 - elif x1 == x2 and y1 > y2: - theta = 3.0 * math.pi / 2.0 - elif x1 == x2 and y2 > y1: - theta = math.pi / 2.0 - elif x2 > x1 and y2 >= y1: - theta = math.atan((y2 - y1) / (x2 - x1)) - elif x2 < x1: - theta = math.pi + math.atan((y2 - y1) / (x2 - x1)) - elif x2 > x1 and y2 < y1: - theta = 2 * math.pi + math.atan((y2 - y1) / (x2 - x1)) - else: - raise "Unknown arrowhead rotation case" + theta = math.atan2(y2 - y1, x2 - x1) % (2 * math.pi) # Rotate about the centre of the object, then place # the object on the line.