summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2020-01-11 15:01:23 +0100
committerPaweł Redman <pawel.redman@gmail.com>2020-01-11 15:01:23 +0100
commitd1fc7360346d8457d088da56c08512b1094d74fe (patch)
tree878aef075c9589f7e1f1e5d37520ad4363c1a1df
parent3e4527837d64a56069e8d7021d810c7c8ac6285f (diff)
Better sphere readability again
-rw-r--r--src/ui_widgets.py60
1 files changed, 51 insertions, 9 deletions
diff --git a/src/ui_widgets.py b/src/ui_widgets.py
index 33a09a1..97f5a0f 100644
--- a/src/ui_widgets.py
+++ b/src/ui_widgets.py
@@ -243,12 +243,9 @@ class PoincareWidget(gl.GLViewWidget):
QSizePolicy.Expanding))
self.setMinimumWidth(200)
- zgrid = gl.GLGridItem()
- zgrid.scale(0.1, 0.1, 0.1)
- self.addItem(zgrid)
-
axis = gl.GLAxisItem()
- axis.scale(0.2, 0.2, 0.2)
+ axis.scale(1.5, 1.5, 1.5)
+ axis.translate(0.001, 0.001, 0.001)
self.addItem(axis)
sphere = gl.GLMeshItem(
@@ -259,6 +256,38 @@ class PoincareWidget(gl.GLViewWidget):
self.arcs = []
+ t = np.linspace(0, 2 * np.pi, 100)
+
+ for lat in np.arange(-90, 91, 5):
+ theta = lat / 180 * np.pi
+ z = np.sin(theta)
+ r = np.cos(theta)
+ points = np.array([
+ r * np.cos(t),
+ r * np.sin(t),
+ z * np.ones(len(t))
+ ])
+ color = [1, 1, 1, 1] if abs(int(lat)) in [0, 15, 30, 45, 60, 90] else [0.3, 0.3, 0.3, 1]
+ circle = gl.GLLinePlotItem(pos=0.997 * np.transpose(points),
+ color=color, width=1, antialias=True,
+ mode="line_strip", glOptions="opaque")
+ self.addItem(circle)
+
+ for lon in np.arange(0, 181, 5):
+ phi = lon / 180 * np.pi
+
+ points = np.array([
+ np.sin(phi) * np.cos(t),
+ np.cos(phi) * np.cos(t),
+ np.sin(t)
+ ])
+
+ color = [1, 1, 1, 1] if int(lon) % 15 == 0 else [0.3, 0.3, 0.3, 1]
+ circle = gl.GLLinePlotItem(pos=0.997 * np.transpose(points),
+ color=color, width=1, antialias=True,
+ mode="line_strip", glOptions="opaque")
+ self.addItem(circle)
+
def make_arc(state, element, N=50):
P = scipy.linalg.fractional_matrix_power(element.matrix(), 1 / N)
@@ -290,16 +319,29 @@ class PoincareWidget(gl.GLViewWidget):
self.removeItem(arc)
self.arcs = []
- for i, element in enumerate(system.elements[1:]):
- state = system.states[i] # i - 1 actually
+ for i, element in enumerate(system.elements[0:]):
+ color = PoincareWidget.colors[i % len(PoincareWidget.colors)]
+ points = 1.5 * np.array([
+ [np.cos(2 * element.angle), np.sin(2 * element.angle)],
+ [-np.cos(2 * element.angle), -np.sin(2 * element.angle)]])
+ arc = gl.GLLinePlotItem(pos=points, color=color,
+ width=2, antialias=True, mode="line_strip",
+ glOptions="opaque")
+ self.addItem(arc)
+ self.arcs.append(arc)
+
+ if i == 0:
+ continue
+
+ state = system.states[i - 1] # i - 1 actually
if state is None:
continue
- color = PoincareWidget.colors[i % len(PoincareWidget.colors)]
-
points = PoincareWidget.make_arc(state, element)
arc = gl.GLLinePlotItem(pos=points, color=color,
width=2, antialias=True, mode="line_strip",
glOptions="opaque")
self.addItem(arc)
self.arcs.append(arc)
+
+