#include <arcball.h>
Public Member Functions | |
CArcball () | |
CArcball (int width, int height, int ox, int oy) | |
CQrot | update (int nx, int ny) |
Private Member Functions | |
void | _plane2sphere (const CPoint2 &v, CPoint &r) |
Private Attributes | |
CPoint | m_position |
double | m_radius |
CPoint2 | m_center |
CArcball Interface.
Arcball interface is widely used for user interaction, because it is intuitive and efficient. Imagine there is a glass ball centered at the screen user can hold one point on the ball, and drag the ball to rotate it. Everything inisde the ball with be roated accordingly.
Definition at line 28 of file arcball.h.
MeshLib::CArcball::CArcball | ( | ) | [inline] |
CArcball::CArcball | ( | int | width, | |
int | height, | |||
int | ox, | |||
int | oy | |||
) |
CArcball constructor
width | width of the window | |
height | height of the window | |
ox | original x position | |
oy | original y position |
Definition at line 16 of file arcball.cpp.
{ m_radius = (win_width < win_height )? win_width/2: win_height/2; m_center = CPoint2( win_width/2, win_height/2 ); CPoint2 p(ox,oy); _plane2sphere( p, m_position ); }
mapping a planar point v to the unit sphere point r
v | input planar point | |
r | output point on the unit sphere |
Definition at line 29 of file arcball.cpp.
{ CPoint2 f = p; f /= m_radius; double l = sqrt( f*f ); if( l > 1.0 ){ q=CPoint( f[0]/l, f[1]/l,0); return; } double fz = sqrt( 1 - l * l ); q = CPoint( f[0],f[1],fz ); }
CQrot CArcball::update | ( | int | nx, | |
int | ny | |||
) |
Update the arcball
nx | current x-position of mouse | |
ny | current y-position of mouse |
Definition at line 49 of file arcball.cpp.
{ CPoint position; _plane2sphere( CPoint2(nx,ny), position ); CPoint cp = m_position^position; CQrot r(m_position * position, cp[0],cp[1],cp[2]); m_position = position; return r; }
CPoint2 MeshLib::CArcball::m_center [private] |
CPoint MeshLib::CArcball::m_position [private] |
double MeshLib::CArcball::m_radius [private] |