move rotate to top

This commit is contained in:
adrienmalin 2018-08-06 15:38:50 +02:00
parent 05f282f698
commit 9d0f2392ca

View File

@ -10,6 +10,17 @@ class Point(QtCore.QPoint):
Point of coordinates (x, y)
"""
def rotate(self, center, direction=CLOCKWISE):
""" Returns the Point image of the rotation of self
through 90° CLOKWISE or COUNTERCLOCKWISE around center"""
if self == center:
return self
p = self - center
p = Point(-direction * p.y(), direction * p.x())
p += center
return p
def __add__(self, o):
return Point(self.x() + o.x(), self.y() + o.y())
@ -27,17 +38,6 @@ class Point(QtCore.QPoint):
__rmul__ = __mul__
__rtruediv__ = __truediv__
def rotate(self, center, direction=CLOCKWISE):
""" Returns the Point image of the rotation of self
through 90° CLOKWISE or COUNTERCLOCKWISE around center"""
if self == center:
return self
p = self - center
p = Point(-direction * p.y(), direction * p.x())
p += center
return p
def __repr__(self):
return "Point({}, {})".format(self.x(), self.y())