Revert Point.angle behavior change (#1806)

* Revert behavior change of Point.angle

* Propagate Point.angle revert
This commit is contained in:
Luke Campagnola 2021-05-27 11:51:06 -04:00 committed by GitHub
parent 1735effea7
commit e29f86578f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

View File

@ -56,7 +56,7 @@ def update():
p2 = pts[i+1] p2 = pts[i+1]
v2 = p2 - p1 v2 = p2 - p1
t = p1 - pts[0] t = p1 - pts[0]
r = v1.angle(v2) r = v2.angle(v1)
s = v2.length() / l1 s = v2.length() / l1
trs.append(pg.SRTTransform({'pos': t, 'scale': (s, s), 'angle': r})) trs.append(pg.SRTTransform({'pos': t, 'scale': (s, s), 'angle': r}))

View File

@ -107,7 +107,7 @@ class Point(QtCore.QPointF):
def angle(self, a, units="degrees"): def angle(self, a, units="degrees"):
""" """
Returns the angle in degrees between this vector and the vector a. Returns the angle in degrees from the vector a to self.
Parameters Parameters
---------- ----------
@ -120,9 +120,9 @@ class Point(QtCore.QPointF):
Returns Returns
------- -------
float float
The angle between the two points The angle between two vectors
""" """
rads = atan2(a.y(), a.x()) - atan2(self.y(), self.x()) rads = atan2(self.y(), self.x()) - atan2(a.y(), a.x())
if units == "radians": if units == "radians":
return rads return rads
return degrees(rads) return degrees(rads)

View File

@ -66,7 +66,7 @@ class SRTTransform(QtGui.QTransform):
dp3 = Point(p3-p1) dp3 = Point(p3-p1)
## detect flipped axes ## detect flipped axes
if dp3.angle(dp2, units="radians") > 0: if dp2.angle(dp3, units="radians") > 0:
da = 0 da = 0
sy = -1.0 sy = -1.0
else: else:

View File

@ -936,7 +936,7 @@ class ROI(GraphicsObject):
return return
## determine new rotation angle, constrained if necessary ## determine new rotation angle, constrained if necessary
ang = newState['angle'] - lp1.angle(lp0) ang = newState['angle'] - lp0.angle(lp1)
if ang is None: ## this should never happen.. if ang is None: ## this should never happen..
return return
if self.rotateSnap or (modifiers & QtCore.Qt.ControlModifier): if self.rotateSnap or (modifiers & QtCore.Qt.ControlModifier):
@ -972,7 +972,7 @@ class ROI(GraphicsObject):
except OverflowError: except OverflowError:
return return
ang = newState['angle'] - lp1.angle(lp0) ang = newState['angle'] - lp0.angle(lp1)
if ang is None: if ang is None:
return return
if self.rotateSnap or (modifiers & QtCore.Qt.ControlModifier): if self.rotateSnap or (modifiers & QtCore.Qt.ControlModifier):
@ -1663,7 +1663,7 @@ class LineROI(ROI):
pos2 = Point(pos2) pos2 = Point(pos2)
d = pos2-pos1 d = pos2-pos1
l = d.length() l = d.length()
ra = d.angle(Point(1, 0), units="radians") ra = Point(1, 0).angle(d, units="radians")
c = Point(-width/2. * sin(ra), -width/2. * cos(ra)) c = Point(-width/2. * sin(ra), -width/2. * cos(ra))
pos1 = pos1 + c pos1 = pos1 + c
@ -2358,7 +2358,7 @@ class RulerROI(LineSegmentROI):
vec = Point(h2) - Point(h1) vec = Point(h2) - Point(h1)
length = vec.length() length = vec.length()
angle = Point(1, 0).angle(vec) angle = vec.angle(Point(1, 0))
pvec = p2 - p1 pvec = p2 - p1
pvecT = Point(pvec.y(), -pvec.x()) pvecT = Point(pvec.y(), -pvec.x())

View File

@ -13,7 +13,7 @@ angles = [
def test_Point_angle(p1, p2, angle): def test_Point_angle(p1, p2, angle):
p1 = pg.Point(*p1) p1 = pg.Point(*p1)
p2 = pg.Point(*p2) p2 = pg.Point(*p2)
assert p1.angle(p2) == angle assert p2.angle(p1) == angle
inits = [ inits = [