Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace Holroyd by Bell
Gavin Bell appears to be the accurate reference/attribution, not Holroyd, replace it.
  • Loading branch information
MischaMegens2 committed Oct 4, 2024
commit a293e31bea61607be481d8889ad84db2a88ca113
24 changes: 14 additions & 10 deletions doc/api/toolkits/mplot3d/view_angles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ mouse movement (it is quite noticeable, especially when adjusting roll),
and it lacks an obvious mechanical equivalent; arguably, the path-independent rotation is unnatural.
So it is a trade-off.

Shoemake's arcball has an abrupt edge; this is remedied in Holroyd's arcball
(``mouserotationstyle: Holroyd``).
Shoemake's arcball has an abrupt edge; this is remedied in Gavin Bell's arcball
(``mouserotationstyle: Bell``), originally written for OpenGL [Bell1988]_. It is used
in Blender and Meshlab.

Henriksen et al. [Henriksen2002]_ provide an overview. In summary:

Expand Down Expand Up @@ -122,7 +123,7 @@ Henriksen et al. [Henriksen2002]_ provide an overview. In summary:
- ✔️
- ✔️
- ❌
* - Holroyd
* - Bell
- ❌
- ✔️
- ✔️
Expand All @@ -142,7 +143,7 @@ You can try out one of the various mouse rotation styles using::
.. code::

import matplotlib as mpl
mpl.rcParams['axes3d.mouserotationstyle'] = 'trackball' # 'azel', 'trackball', 'arcball', 'Shoemake', or 'Holroyd'
mpl.rcParams['axes3d.mouserotationstyle'] = 'trackball' # 'azel', 'trackball', 'arcball', 'Shoemake', or 'Bell'

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -183,11 +184,14 @@ A size of about 2/3 appears to work reasonably well; this is the default.
three-dimensional rotation using a mouse", in Proceedings of Graphics
Interface '92, 1992, pp. 151-156, https://doi.org/10.20380/GI1992.18


.. [Bell1988] Gavin Bell, in the examples included with the GLUT (OpenGL
Utility Toolkit) library,
https://github.com/markkilgard/glut/blob/master/progs/examples/trackball.h

.. [Henriksen2002] Knud Henriksen, Jon Sporring, Kasper Hornbæk,
"Virtual Trackballs Revisited", in Proceedings of DSAGM'2002
`[pdf]`__;
and in IEEE Transactions on Visualization and Computer Graphics,
Volume 10, Issue 2, March-April 2004, pp. 206-216,
https://doi.org/10.1109/TVCG.2004.1260772
"Virtual Trackballs Revisited", in IEEE Transactions on Visualization
and Computer Graphics, Volume 10, Issue 2, March-April 2004, pp. 206-216,
https://doi.org/10.1109/TVCG.2004.1260772 `[full-text]`__;

__ https://web.archive.org/web/20240607102518/http://hjemmesider.diku.dk/~kash/papers/DSAGM2002_henriksen.pdf
__ https://www.researchgate.net/publication/8329656_Virtual_Trackballs_Revisited#fullTextFileContent
2 changes: 1 addition & 1 deletion doc/users/next_whats_new/mouse_rotation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To try out one of the various mouse rotation styles:
.. code::

import matplotlib as mpl
mpl.rcParams['axes3d.mouserotationstyle'] = 'trackball' # 'azel', 'trackball', 'arcball', 'Shoemake', or 'Holroyd'
mpl.rcParams['axes3d.mouserotationstyle'] = 'trackball' # 'azel', 'trackball', 'arcball', 'Shoemake', or 'Bell'

import numpy as np
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/mpl-data/matplotlibrc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@
#axes3d.yaxis.panecolor: (0.90, 0.90, 0.90, 0.5) # background pane on 3D axes
#axes3d.zaxis.panecolor: (0.925, 0.925, 0.925, 0.5) # background pane on 3D axes

#axes3d.mouserotationstyle: arcball # {azel, trackball, arcball, Shoemake, Holroyd}
#axes3d.mouserotationstyle: arcball # {azel, trackball, arcball, Shoemake, Bell}
# See also https://matplotlib.org/stable/api/toolkits/mplot3d/view_angles.html#rotation-with-mouse
#axes3d.trackballsize: 0.667 # trackball diameter, in units of the Axes bbox

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ def _convert_validator_spec(key, conv):
"axes3d.zaxis.panecolor": validate_color, # 3d background pane

"axes3d.mouserotationstyle": ["azel", "trackball", "arcball",
"Shoemake", "Holroyd"],
"Shoemake", "Bell"],
"axes3d.trackballsize": validate_float,

# scatter props
Expand Down
8 changes: 4 additions & 4 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ def _arcball(self, x: float, y: float, style: str) -> np.ndarray:
Convert a point (x, y) to a point on a virtual trackball.

This is either Ken Shoemake's arcball (a sphere) or
Tom Holroyd's (a sphere combined with a hyperbola).
Gavin Bell's (a sphere combined with a hyperbola).
See: Ken Shoemake, "ARCBALL: A user interface for specifying
three-dimensional rotation using a mouse." in
Proceedings of Graphics Interface '92, 1992, pp. 151-156,
Expand All @@ -1523,7 +1523,7 @@ def _arcball(self, x: float, y: float, style: str) -> np.ndarray:
x /= s
y /= s
r2 = x*x + y*y
if style == 'Holroyd':
if style == 'Bell':
if r2 > 0.5:
p = np.array([1/(2*math.sqrt(r2)), x, y])/math.sqrt(1/(4*r2)+r2)
else:
Expand Down Expand Up @@ -1587,12 +1587,12 @@ def _on_move(self, event):
nk = np.linalg.norm(k)
th = nk / mpl.rcParams['axes3d.trackballsize']
dq = _Quaternion(np.cos(th), k*np.sin(th)/nk)
else: # 'arcball', 'Shoemake', 'Holroyd'
else: # 'arcball', 'Shoemake', 'Bell'
current_vec = self._arcball(self._sx/w, self._sy/h, style)
new_vec = self._arcball(x/w, y/h, style)
if style == 'arcball':
dq = _Quaternion.rotate_from_to(current_vec, new_vec)
else: # 'Shoemake', 'Holroyd'
else: # 'Shoemake', 'Bell'
dq = _Quaternion(0, new_vec) * _Quaternion(0, -current_vec)

q = dq * q
Expand Down
16 changes: 8 additions & 8 deletions lib/mpl_toolkits/mplot3d/tests/test_axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ def test_quaternion():


@pytest.mark.parametrize('style',
('azel', 'trackball', 'arcball', 'Shoemake', 'Holroyd'))
('azel', 'trackball', 'arcball', 'Shoemake', 'Bell'))
def test_rotate(style):
"""Test rotating using the left mouse button."""
if style == 'azel':
Expand Down Expand Up @@ -2008,13 +2008,13 @@ def test_rotate(style):
('Shoemake', 30, 0, 1): (-48.590378, -40.893395, 49.106605),
('Shoemake', 30, 0.5, c): (-25.658906, -56.309932, 43.897886),

('Holroyd', 0, 1, 0): (0, -60, 0),
('Holroyd', 0, 0, 1): (-60, 0, 0),
('Holroyd', 0, 0.5, c): (-48.590378, -40.893395, 19.106605),
('Holroyd', 0, 2, 0): (0, -126.869898, 0),
('Holroyd', 30, 1, 0): (25.658906, -56.309932, 16.102114),
('Holroyd', 30, 0, 1): (-48.590378, -40.893395, 49.106605),
('Holroyd', 30, 0.5, c): (-25.658906, -56.309932, 43.897886)}
('Bell', 0, 1, 0): (0, -60, 0),
('Bell', 0, 0, 1): (-60, 0, 0),
('Bell', 0, 0.5, c): (-48.590378, -40.893395, 19.106605),
('Bell', 0, 2, 0): (0, -126.869898, 0),
('Bell', 30, 1, 0): (25.658906, -56.309932, 16.102114),
('Bell', 30, 0, 1): (-48.590378, -40.893395, 49.106605),
('Bell', 30, 0.5, c): (-25.658906, -56.309932, 43.897886)}
new_elev, new_azim, new_roll = expectations[(style, roll, dx, dy)]
np.testing.assert_allclose((ax.elev, ax.azim, ax.roll),
(new_elev, new_azim, new_roll), atol=1e-6)
Expand Down