Geogram
Version 1.9.1-rc
A programming library of geometric algorithms
|
Enables to interactively define a rotation. More...
#include <geogram_gfx/gui/arc_ball.h>
Public Member Functions | |
ArcBall () | |
ArcBall constructor. | |
const mat4 & | get_value () const |
Gets the value of the rotation. More... | |
void | set_value (const mat4 &value) |
Sets the value of the rotation. More... | |
bool | get_x_constraint () const |
Tests whether the X axis is constrained. More... | |
void | set_x_constraint (bool value) |
Specifies whether the X axis is constrained. More... | |
bool | get_y_constraint () const |
Tests whether the Y axis is constrained. More... | |
void | set_y_constraint (bool value) |
Specifies whether the Y axis is constrained. More... | |
void | grab (const vec2 &value) |
Callback called when the mouse is clicked. More... | |
void | drag (const vec2 &value) |
Callback called when the mouse is moved. More... | |
void | release (const vec2 &value) |
Callback called when the mouse button is released. More... | |
void | reset () |
Resets this ArcBall to the default value. | |
bool | grabbed () const |
Tests whether this ArcBall is grabbed. More... | |
Protected Member Functions | |
vec3 | constrain_vector (const vec3 &vector, const vec3 &axis) const |
Discards the component of a vector that is along another vector. More... | |
vec3 | mouse_to_sphere (const vec2 &p) |
Lifts a 2d screen coordinate to 3d sphere coordinates, and applies the X or Y axis constraints. More... | |
Enables to interactively define a rotation.
This class is inspired by an implementation written by Paul Rademacher, in his glui library. Initial documentation by Paul Rademacher: A C++ class that implements the Arcball, as described by Ken Shoemake in Graphics Gems IV. This class takes as input mouse events (mouse down, mouse drag, mouse up), and creates the appropriate quaternions and 4x4 matrices to represent the rotation given by the mouse.
Definition at line 66 of file arc_ball.h.
Discards the component of a vector that is along another vector.
[in] | vector | the input vector |
[in] | axis | the axis along which the component should be discarded |
vector
onto the plane perpendicular to axis
void GEO::ArcBall::drag | ( | const vec2 & | value | ) |
Callback called when the mouse is moved.
[in] | value | the point under the mouse pointer, in normalized device coordinates (x and y both in [-1.0, 1.0]). |
|
inline |
Gets the value of the rotation.
Definition at line 78 of file arc_ball.h.
|
inline |
Tests whether the X axis is constrained.
true | if the X axis is constrained |
false | otherwise |
Definition at line 94 of file arc_ball.h.
|
inline |
Tests whether the Y axis is constrained.
true | if the Y axis is constrained |
false | otherwise |
Definition at line 112 of file arc_ball.h.
void GEO::ArcBall::grab | ( | const vec2 & | value | ) |
Callback called when the mouse is clicked.
[in] | value | the picked point, in normalized device coordinates (x and y both in [-1.0, 1.0]). |
|
inline |
Tests whether this ArcBall is grabbed.
true | if this ArcBall is grabbed. |
false | otherwise. |
Definition at line 156 of file arc_ball.h.
Lifts a 2d screen coordinate to 3d sphere coordinates, and applies the X or Y axis constraints.
[in] | p | the point, in normalized device coordinates (both X and Y coordinates in [-1.0, 1.0]) |
void GEO::ArcBall::release | ( | const vec2 & | value | ) |
Callback called when the mouse button is released.
[in] | value | the point under the mouse pointer, in normalized device coordinates (x and y both in [-1.0, 1.0]). |
void GEO::ArcBall::set_value | ( | const mat4 & | value | ) |
Sets the value of the rotation.
[in] | value | the rotation, as a 4x4 matrix (with a zero translational component). |
|
inline |
Specifies whether the X axis is constrained.
[in] | value | true if the X axis should be constrained, false otherwise |
Definition at line 103 of file arc_ball.h.
|
inline |
Specifies whether the Y axis is constrained.
[in] | value | true if the Y axis should be constrained, false otherwise |
Definition at line 121 of file arc_ball.h.