trackball.hpp
Go to the documentation of this file.
1 /*
2 ** TP CPE Lyon
3 ** Copyright (C) 2014 Damien Rohmer
4 **
5 ** This program is free software: you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation, either version 3 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 #pragma once
21 
22 #ifndef TRACKBALL_HPP
23 # define TRACKBALL_HPP
24 
25 
26 
27 
28 #include "../lib3d/quaternion.hpp"
29 
30 namespace cpe
31 {
32 
34  class trackball
35  {
36  public:
37 
38  // ********************************************* //
39  // ********************************************* //
40  // CONSTRUCTORS
41  // ********************************************* //
42  // ********************************************* //
43 
45  trackball();
46 
47 
48  //*********************************************//
49  //*********************************************//
50  // Get quaternion
51  //*********************************************//
52  //*********************************************//
53 
55  const quaternion& quat() const;
57  quaternion& quat();
58 
60  const quaternion& d_quat() const;
62  quaternion& d_quat();
63 
64  //*********************************************//
65  //*********************************************//
66  // Disc radius
67  //*********************************************//
68  //*********************************************//
69 
71  float& radius();
73  float radius() const;
74 
75  //*********************************************//
76  //*********************************************//
77  // Manipulation
78  //*********************************************//
79  //*********************************************//
80 
82  double project_to_disc(float x,float y) const;
83 
85  void set_2d_coords(float x0,float y0,float x1,float y1);
86 
88  void apply_rotation();
89 
91  void no_motion();
92 
93 
94 
95 
96 
97  private:
98 
103 
105  float disc_radius;
106 
107  };
108 
109 }
110 
111 #endif
float & radius()
get the disc radius
Definition: trackball.cpp:86
const quaternion & quat() const
get the current quaternion
Definition: trackball.cpp:80
void apply_rotation()
multiply d_q to current_q
Definition: trackball.cpp:74
void no_motion()
Set d_q to 0.
Definition: trackball.cpp:76
float disc_radius
internal parameter of the disc radius
Definition: trackball.hpp:105
const quaternion & d_quat() const
get the quaternion to apply
Definition: trackball.cpp:83
Quaternion class.
Definition: quaternion.hpp:31
quaternion d_q
the quaternion to apply
Definition: trackball.hpp:102
A container class to deal with a trackball, use ArcBall paradigm.
Definition: trackball.hpp:34
quaternion current_q
the current quaternion
Definition: trackball.hpp:100
double project_to_disc(float x, float y) const
return the distance to disc for the 3D coordinate
Definition: trackball.cpp:35
void set_2d_coords(float x0, float y0, float x1, float y1)
given a set of 2d coords difference, return the corresponding quaternion
Definition: trackball.cpp:44
trackball()
Definition: trackball.cpp:28