Use np.pi or math.pi instead of just pi
This commit is contained in:
parent
6a386e723b
commit
e1415cb3a8
@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from math import atan2, asin, sin, cos, sqrt, pi, hypot
|
from math import atan2, asin, sin, cos, degrees, sqrt, hypot
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
from pyqtgraph.Qt import QtGui, QtCore
|
from pyqtgraph.Qt import QtGui, QtCore
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -285,7 +285,7 @@ class Mirror(Optic):
|
|||||||
p1 = surface.mapToItem(ray, p1)
|
p1 = surface.mapToItem(ray, p1)
|
||||||
rd = ray['dir']
|
rd = ray['dir']
|
||||||
a1 = atan2(rd[1], rd[0])
|
a1 = atan2(rd[1], rd[0])
|
||||||
ar = a1 + pi - 2*ai
|
ar = a1 + np.pi - 2 * ai
|
||||||
ray.setEnd(p1)
|
ray.setEnd(p1)
|
||||||
dp = Point(cos(ar), sin(ar))
|
dp = Point(cos(ar), sin(ar))
|
||||||
ray = Ray(parent=ray, dir=dp)
|
ray = Ray(parent=ray, dir=dp)
|
||||||
@ -379,7 +379,7 @@ class CircleSurface(pg.GraphicsObject):
|
|||||||
## half-height of surface can't be larger than radius
|
## half-height of surface can't be larger than radius
|
||||||
h2 = min(h2, abs(r))
|
h2 = min(h2, abs(r))
|
||||||
arc = QtCore.QRectF(0, -r, r*2, r*2)
|
arc = QtCore.QRectF(0, -r, r*2, r*2)
|
||||||
a1 = asin(h2/r) * 180. / pi
|
a1 = degrees(asin(h2/r))
|
||||||
a2 = -2*a1
|
a2 = -2*a1
|
||||||
a1 += 180.
|
a1 += 180.
|
||||||
self.path.arcMoveTo(arc, a1)
|
self.path.arcMoveTo(arc, a1)
|
||||||
@ -443,7 +443,7 @@ class CircleSurface(pg.GraphicsObject):
|
|||||||
|
|
||||||
norm = atan2(pt[1], pt[0])
|
norm = atan2(pt[1], pt[0])
|
||||||
if r < 0:
|
if r < 0:
|
||||||
norm += pi
|
norm += np.pi
|
||||||
dp = p - pt
|
dp = p - pt
|
||||||
ang = atan2(dp[1], dp[0])
|
ang = atan2(dp[1], dp[0])
|
||||||
return pt + Point(r, 0), ang-norm
|
return pt + Point(r, 0), ang-norm
|
||||||
|
@ -17,7 +17,7 @@ import numpy as np
|
|||||||
#from numpy.linalg import norm
|
#from numpy.linalg import norm
|
||||||
from ..Point import *
|
from ..Point import *
|
||||||
from ..SRTTransform import SRTTransform
|
from ..SRTTransform import SRTTransform
|
||||||
from math import atan2, cos, sin, pi, sqrt, hypot, radians, degrees
|
from math import atan2, cos, sin, hypot, radians, degrees
|
||||||
from .. import functions as fn
|
from .. import functions as fn
|
||||||
from .GraphicsObject import GraphicsObject
|
from .GraphicsObject import GraphicsObject
|
||||||
from .UIGraphicsItem import UIGraphicsItem
|
from .UIGraphicsItem import UIGraphicsItem
|
||||||
@ -1332,8 +1332,8 @@ class Handle(UIGraphicsItem):
|
|||||||
properties of the ROI they are attached to.
|
properties of the ROI they are attached to.
|
||||||
"""
|
"""
|
||||||
types = { ## defines number of sides, start angle for each handle type
|
types = { ## defines number of sides, start angle for each handle type
|
||||||
't': (4, pi/4),
|
't': (4, np.pi/4),
|
||||||
'f': (4, pi/4),
|
'f': (4, np.pi/4),
|
||||||
's': (4, 0),
|
's': (4, 0),
|
||||||
'r': (12, 0),
|
'r': (12, 0),
|
||||||
'sr': (12, 0),
|
'sr': (12, 0),
|
||||||
@ -1481,7 +1481,7 @@ class Handle(UIGraphicsItem):
|
|||||||
size = self.radius
|
size = self.radius
|
||||||
self.path = QtGui.QPainterPath()
|
self.path = QtGui.QPainterPath()
|
||||||
ang = self.startAng
|
ang = self.startAng
|
||||||
dt = 2 * pi / self.sides
|
dt = 2 * np.pi / self.sides
|
||||||
for i in range(0, self.sides+1):
|
for i in range(0, self.sides+1):
|
||||||
x = size * cos(ang)
|
x = size * cos(ang)
|
||||||
y = size * sin(ang)
|
y = size * sin(ang)
|
||||||
@ -1911,7 +1911,7 @@ class EllipseROI(ROI):
|
|||||||
center = br.center()
|
center = br.center()
|
||||||
r1 = br.width() / 2.
|
r1 = br.width() / 2.
|
||||||
r2 = br.height() / 2.
|
r2 = br.height() / 2.
|
||||||
theta = np.linspace(0, 2 * pi, 24)
|
theta = np.linspace(0, 2 * np.pi, 24)
|
||||||
x = center.x() + r1 * np.cos(theta)
|
x = center.x() + r1 * np.cos(theta)
|
||||||
y = center.y() + r2 * np.sin(theta)
|
y = center.y() + r2 * np.sin(theta)
|
||||||
path.moveTo(x[0], y[0])
|
path.moveTo(x[0], y[0])
|
||||||
@ -2394,6 +2394,8 @@ class TriangleROI(ROI):
|
|||||||
ROI.__init__(self, pos, [size, size], **args)
|
ROI.__init__(self, pos, [size, size], **args)
|
||||||
self.aspectLocked = True
|
self.aspectLocked = True
|
||||||
angles = np.linspace(0, pi * 4 / 3, 3)
|
angles = np.linspace(0, pi * 4 / 3, 3)
|
||||||
|
ROI.__init__(self, pos, [size, size], aspectLocked=True, **args)
|
||||||
|
angles = np.linspace(0, np.pi * 4 / 3, 3)
|
||||||
verticies = (np.array((np.sin(angles), np.cos(angles))).T + 1.0) / 2.0
|
verticies = (np.array((np.sin(angles), np.cos(angles))).T + 1.0) / 2.0
|
||||||
self.poly = QtGui.QPolygonF()
|
self.poly = QtGui.QPolygonF()
|
||||||
for pt in verticies:
|
for pt in verticies:
|
||||||
|
Loading…
Reference in New Issue
Block a user