\( %\long\def\block#1#2{\begin{#1}#2\end{#1}} \def\amp{&} \def\block#1#2{\begin{#1}#2\end{#1}} \def\L{\left} \def\R{\right} \def\if{\text{if}\quad} \def\otherwise{\text{otherwise}} \def\qi{\boldsymbol{i}} \def\qj{\boldsymbol{j}} \def\qk{\boldsymbol{k}} \def\qp{\boldsymbol{p}} \def\qq{\boldsymbol{q}} \def\qv{\boldsymbol{v}} \def\vp{\vec{p}} \def\vv{\vec{v}} \)

Improving the method to rotate a 3D object by a 2D pointer

0. Abstract

Under construction...

1. Demo

The mapping method from the screen to the virtual sphere
The amount of rotation

Alicia Solid by 黒星紅白 and 雨刻, using three.js.

2. Notation

$$ \block{array}{{cl} x \amp \text{ Real numbers.} \\ \qi, \qj, \qk \amp \text{ Unit quaternions } (\qi^2 = \qj^2 = \qk^2 = \qi \qj \qk = -1). \\ \qq = q_0 + q_1 \qi + q_2 \qj + q_3 \qk \amp \text{ Quaternions and their elements.} \\ \vv = (v_1, v_2, v_3) \amp \text{ 2d or 3d vectors and their elements.} \\ \qv = v_1 \qi + v_2 \qj + v_3 \qk \amp \text{ Implicit conversion from 3d vectors } \vv \text{ to quaternions } \qv. } $$

3. Foo

Foo

4. Bar

Bar

5. Appendix

Screen coodinates \( \vv \in \mathbb{R}^2 \) to the points on the unit sphere \( \vp \in \mathbb{R}^3 ,\, |\vp| = 1 \) :

Azimuthal equidistant (My proposal) $$ \block{align}{ (p_1,\, p_2) \amp= \sin \L( \frac{\pi}{2} |\vv| \R) \, \frac{\vv}{|\vv|} \\ p_3 \amp= \cos \L( \frac{\pi}{2} |\vv| \R) } $$
Orthographic (Shoemake) $$ \block{align}{ (p_1,\, p_2) \amp= \vv \\ p_3 \amp= \sqrt{1 - {|\vv|}^2} \amp\amp \if {|\vv|}^2 \lt 1, \\ \\ (p_1,\, p_2) \amp= \frac{\vv}{|\vv|} \\ p_3 \amp= 0 \amp\amp \otherwise. } $$
Orthographic + hyperbola (Holroyd) $$ \block{align}{ (p_1, \, p_2) \amp= \vv \\ p_3 \amp= \sqrt{1 - {|\vv|}^2} \amp\amp \if {|\vv|}^2 \lt \frac{1}{2}, \\ \\ (\tilde{p}_1,\, \tilde{p}_2) \amp:= \vv \\ \tilde{p}_3 \amp:= \frac{1}{2 |\vv|} \\ \vp \amp= \frac{\vec{\tilde{p}}}{|\vec{\tilde{p}}|} \amp\amp \otherwise. } $$

Point pairs \( \vp_0, \ \vp_1 \) on the unit sphere to the rotation \( \qq \in \mathbb{H} \) :

$$ \cos \theta := {\vp_0} \cdot {\vp_1} \,,\, \vec{a} := \frac{ \vp_0 \times \vp_1 }{ | \vp_0 \times \vp_1 | } $$

1×, path dependent $$ \qq = \cos \frac{\theta}{2} + \boldsymbol{a} \sin \frac{\theta}{2} $$
2×, path independent (Shoemake) $$ \qq = \cos \theta + \boldsymbol{a} \sin \theta = \qp_1 \, \bar{\qp}_0 $$

6. References

© Yasuhiro Fujii <y-fujii at mimosa-pudica.net>, under CC-BY.