diff options
-rw-r--r-- | src/ui_widgets.py | 60 |
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) + + |