Virtual Trackball Orbiting via the Exponential Map
This is an alternative trackball technique using exponential map and parallel transport to preserve distances and angles for inducing coherent and intuitive trackball rotations. For instance, displacements on straight radial lines through the screen's center are carried to arcs of the same length on great circles of the trackball. This is in contrast to state-of-the-art techniques using orthogonal projection which distorts radial distances further away from the screen's center. This implementation strictly follows the recipe given in the paper of Stantchev, G.. “Virtual Trackball Modeling and the Exponential Map.” . S2CID.
Orbit
] operation handler.Orbit
] operation handler behind cc
feature gate.Frame
] with [Frame::slide()
], [Frame::orbit()
], [Frame::scale()
]
operations in world space and their local complements in camera space.Clamp
] operation handler ensuring user boundary conditions of observer [Frame
].Fixed
] quantities wrt to field of view, see [Scene::set_fov()
].Touch
] gesture recognition for slide, orbit, scale, and focus operations.See the release history to keep track of the development.
A trackball camera mode implementation can be as easy as this by delegating events of your 3D
graphics library of choice to the [Orbit
] operation handler along with other handlers.
```rust use nalgebra::{Point2, UnitQuaternion, Vector3}; use std::f32::consts::PI; use trackball::{Frame, Image, Orbit};
/// Trackball camera mode.
pub struct Trackball {
// Frame wrt camera eye and target.
frame: FrameScene
wrt Frame
.
image: Image
impl Trackball {
// Usually, a cursor position event with left mouse button being pressed.
fn handleleftbuttondisplacement(&mut self, pos: &Point2Self::handle_left_button_press()
.
self.orbit.discard();
}
}
```
Identical C11 implementation for [Orbit
] operation handler behind cc
feature gate:
toml
[dependencies]
trackball = { version = "0.3", features = ["cc"] }
The works are licensed under the [BSD-2-Clause-Patent
].
This license is designed to provide:
GPL-2.0-or-later
], andUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the works by you shall be licensed as above, without any additional terms or conditions.