Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
GEO::ArcBall Class Reference

Enables to interactively define a rotation. More...

#include <geogram_gfx/gui/arc_ball.h>

Public Member Functions

 ArcBall ()
 ArcBall constructor.
 
const mat4get_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...
 

Detailed Description

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.

Member Function Documentation

◆ constrain_vector()

vec3 GEO::ArcBall::constrain_vector ( const vec3 vector,
const vec3 axis 
) const
protected

Discards the component of a vector that is along another vector.

Parameters
[in]vectorthe input vector
[in]axisthe axis along which the component should be discarded
Returns
the projection of vector onto the plane perpendicular to axis

◆ drag()

void GEO::ArcBall::drag ( const vec2 value)

Callback called when the mouse is moved.

Parameters
[in]valuethe point under the mouse pointer, in normalized device coordinates (x and y both in [-1.0, 1.0]).

◆ get_value()

const mat4& GEO::ArcBall::get_value ( ) const
inline

Gets the value of the rotation.

Returns
the computed rotation, as a 4x4 matrix (with a zero translational component).

Definition at line 78 of file arc_ball.h.

◆ get_x_constraint()

bool GEO::ArcBall::get_x_constraint ( ) const
inline

Tests whether the X axis is constrained.

Return values
trueif the X axis is constrained
falseotherwise

Definition at line 94 of file arc_ball.h.

◆ get_y_constraint()

bool GEO::ArcBall::get_y_constraint ( ) const
inline

Tests whether the Y axis is constrained.

Return values
trueif the Y axis is constrained
falseotherwise

Definition at line 112 of file arc_ball.h.

◆ grab()

void GEO::ArcBall::grab ( const vec2 value)

Callback called when the mouse is clicked.

Parameters
[in]valuethe picked point, in normalized device coordinates (x and y both in [-1.0, 1.0]).

◆ grabbed()

bool GEO::ArcBall::grabbed ( ) const
inline

Tests whether this ArcBall is grabbed.

Return values
trueif this ArcBall is grabbed.
falseotherwise.

Definition at line 156 of file arc_ball.h.

◆ mouse_to_sphere()

vec3 GEO::ArcBall::mouse_to_sphere ( const vec2 p)
protected

Lifts a 2d screen coordinate to 3d sphere coordinates, and applies the X or Y axis constraints.

Parameters
[in]pthe point, in normalized device coordinates (both X and Y coordinates in [-1.0, 1.0])
Returns
the point lifted on the 3d sphere. X or Y can be constrained to zero according to the status of get_x_constraint() and get_y_constraint() respectively.

◆ release()

void GEO::ArcBall::release ( const vec2 value)

Callback called when the mouse button is released.

Parameters
[in]valuethe point under the mouse pointer, in normalized device coordinates (x and y both in [-1.0, 1.0]).

◆ set_value()

void GEO::ArcBall::set_value ( const mat4 value)

Sets the value of the rotation.

Parameters
[in]valuethe rotation, as a 4x4 matrix (with a zero translational component).

◆ set_x_constraint()

void GEO::ArcBall::set_x_constraint ( bool  value)
inline

Specifies whether the X axis is constrained.

Parameters
[in]valuetrue if the X axis should be constrained, false otherwise

Definition at line 103 of file arc_ball.h.

◆ set_y_constraint()

void GEO::ArcBall::set_y_constraint ( bool  value)
inline

Specifies whether the Y axis is constrained.

Parameters
[in]valuetrue if the Y axis should be constrained, false otherwise

Definition at line 121 of file arc_ball.h.


The documentation for this class was generated from the following file: