@@ -1503,21 +1503,22 @@ def _calc_coord(self, xv, yv, renderer=None):
1503
1503
p2 = p1 - scale * vec
1504
1504
return p2 , pane_idx
1505
1505
1506
- def _arcball (self , p ) :
1506
+ def _arcball (self , x : float , y : float ) -> np . ndarray :
1507
1507
"""
1508
- Convert a point p = [ x, y] to a point on a virtual trackball
1508
+ Convert a point ( x, y) to a point on a virtual trackball
1509
1509
This is Ken Shoemake's arcball
1510
1510
See: Ken Shoemake, "ARCBALL: A user interface for specifying
1511
1511
three-dimensional rotation using a mouse." in
1512
1512
Proceedings of Graphics Interface '92, 1992, pp. 151-156,
1513
1513
https://doi.org/10.20380/GI1992.18
1514
1514
"""
1515
- p = 2 * p
1516
- r = p [0 ]** 2 + p [1 ]** 2
1517
- if r > 1 :
1518
- p = np .concatenate (([0 ], p / math .sqrt (r )))
1515
+ x *= 2
1516
+ y *= 2
1517
+ r2 = x * x + y * y
1518
+ if r2 > 1 :
1519
+ p = np .array ([0 , x / math .sqrt (r2 ), y / math .sqrt (r2 )])
1519
1520
else :
1520
- p = np .concatenate (( [math .sqrt (1 - r )], p ) )
1521
+ p = np .array ( [math .sqrt (1 - r2 ), x , y ] )
1521
1522
return p
1522
1523
1523
1524
def _on_move (self , event ):
@@ -1562,12 +1563,10 @@ def _on_move(self, event):
1562
1563
q = _Quaternion .from_cardan_angles (elev , azim , roll )
1563
1564
1564
1565
# Update quaternion - a variation on Ken Shoemake's ARCBALL
1565
- current_point = np .array ([self ._sx / w , self ._sy / h ])
1566
- new_point = np .array ([x / w , y / h ])
1567
- current_vec = self ._arcball (current_point )
1568
- new_vec = self ._arcball (new_point )
1566
+ current_vec = self ._arcball (self ._sx / w , self ._sy / h )
1567
+ new_vec = self ._arcball (x / w , y / h )
1569
1568
dq = _Quaternion .rotate_from_to (current_vec , new_vec )
1570
- q = dq * q
1569
+ q = dq * q
1571
1570
1572
1571
# Convert to elev, azim, roll
1573
1572
elev , azim , roll = q .as_cardan_angles ()
0 commit comments