Skip to content

Commit

Permalink
MRG: Correct camera view_up when necessary (mne-tools#7187)
Browse files Browse the repository at this point in the history
* Correct camera view_up when necessary

* Handle the case when elevation is None
  • Loading branch information
GuillaumeFavelier authored and AdoNunes committed Apr 6, 2020
1 parent d7b5aff commit ed8eb9b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mne/viz/backends/_pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,20 @@ def _set_3d_view(figure, azimuth, elevation, focalpoint, distance):
if focalpoint is not None:
cen = np.asarray(focalpoint)

# Now calculate the view_up vector of the camera. If the view up is
# close to the 'z' axis, the view plane normal is parallel to the
# camera which is unacceptable, so we use a different view up.
if elevation is None or 5. <= abs(elevation) <= 175.:
view_up = [0, 0, 1]
else:
view_up = [np.sin(phi), np.cos(phi), 0]

position = [
r * np.cos(phi) * np.sin(theta),
r * np.sin(phi) * np.sin(theta),
r * np.cos(theta)]
figure.plotter.camera_position = [
position, cen, [0, 0, 1]]
position, cen, view_up]


def _set_3d_title(figure, title, size=40):
Expand Down

0 comments on commit ed8eb9b

Please sign in to comment.