Revert Point.angle behavior change (#1806)
* Revert behavior change of Point.angle * Propagate Point.angle revert
This commit is contained in:
parent
1735effea7
commit
e29f86578f
@ -56,7 +56,7 @@ def update():
|
||||
p2 = pts[i+1]
|
||||
v2 = p2 - p1
|
||||
t = p1 - pts[0]
|
||||
r = v1.angle(v2)
|
||||
r = v2.angle(v1)
|
||||
s = v2.length() / l1
|
||||
trs.append(pg.SRTTransform({'pos': t, 'scale': (s, s), 'angle': r}))
|
||||
|
||||
|
@ -107,7 +107,7 @@ class Point(QtCore.QPointF):
|
||||
|
||||
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
|
||||
----------
|
||||
@ -120,9 +120,9 @@ class Point(QtCore.QPointF):
|
||||
Returns
|
||||
-------
|
||||
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":
|
||||
return rads
|
||||
return degrees(rads)
|
||||
|
@ -66,7 +66,7 @@ class SRTTransform(QtGui.QTransform):
|
||||
dp3 = Point(p3-p1)
|
||||
|
||||
## detect flipped axes
|
||||
if dp3.angle(dp2, units="radians") > 0:
|
||||
if dp2.angle(dp3, units="radians") > 0:
|
||||
da = 0
|
||||
sy = -1.0
|
||||
else:
|
||||
|
@ -936,7 +936,7 @@ class ROI(GraphicsObject):
|
||||
return
|
||||
|
||||
## 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..
|
||||
return
|
||||
if self.rotateSnap or (modifiers & QtCore.Qt.ControlModifier):
|
||||
@ -972,7 +972,7 @@ class ROI(GraphicsObject):
|
||||
except OverflowError:
|
||||
return
|
||||
|
||||
ang = newState['angle'] - lp1.angle(lp0)
|
||||
ang = newState['angle'] - lp0.angle(lp1)
|
||||
if ang is None:
|
||||
return
|
||||
if self.rotateSnap or (modifiers & QtCore.Qt.ControlModifier):
|
||||
@ -1663,7 +1663,7 @@ class LineROI(ROI):
|
||||
pos2 = Point(pos2)
|
||||
d = pos2-pos1
|
||||
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))
|
||||
pos1 = pos1 + c
|
||||
|
||||
@ -2358,7 +2358,7 @@ class RulerROI(LineSegmentROI):
|
||||
|
||||
vec = Point(h2) - Point(h1)
|
||||
length = vec.length()
|
||||
angle = Point(1, 0).angle(vec)
|
||||
angle = vec.angle(Point(1, 0))
|
||||
|
||||
pvec = p2 - p1
|
||||
pvecT = Point(pvec.y(), -pvec.x())
|
||||
|
@ -13,7 +13,7 @@ angles = [
|
||||
def test_Point_angle(p1, p2, angle):
|
||||
p1 = pg.Point(*p1)
|
||||
p2 = pg.Point(*p2)
|
||||
assert p1.angle(p2) == angle
|
||||
assert p2.angle(p1) == angle
|
||||
|
||||
|
||||
inits = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user