00001 /* 00002 ** Projet etudiants CPE Lyon 00003 ** Copyright (C) 2012 Damien Rohmer 00004 ** 00005 ** This program is free software: you can redistribute it and/or modify 00006 ** it under the terms of the GNU General Public License as published by 00007 ** the Free Software Foundation, either version 3 of the License, or 00008 ** (at your option) any later version. 00009 ** 00010 ** This program is distributed in the hope that it will be useful, 00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 ** GNU General Public License for more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #ifndef TRACKBALL_HPP 00020 # define TRACKBALL_HPP 00021 00022 00023 00024 00025 #include <quaternion.hpp> 00026 00027 namespace cpe 00028 { 00029 00031 class trackball 00032 { 00033 public: 00034 00035 // ********************************************* // 00036 // ********************************************* // 00037 // CONSTRUCTORS 00038 // ********************************************* // 00039 // ********************************************* // 00040 00042 trackball(); 00043 00044 00045 //*********************************************// 00046 //*********************************************// 00047 // Get quaternion 00048 //*********************************************// 00049 //*********************************************// 00050 00052 const quaternion& quat() const; 00054 quaternion& quat(); 00055 00057 const quaternion& d_quat() const; 00059 quaternion& d_quat(); 00060 00061 //*********************************************// 00062 //*********************************************// 00063 // Disc radius 00064 //*********************************************// 00065 //*********************************************// 00066 00068 double& radius(); 00070 const double& radius() const; 00071 00072 //*********************************************// 00073 //*********************************************// 00074 // Manipulation 00075 //*********************************************// 00076 //*********************************************// 00077 00079 double project_to_disc(const double& x,const double& y) const; 00080 00082 void set_2d_coords(const double& x0,const double& y0,const double& x1,const double& y1); 00083 00085 void apply_rotation(); 00086 00088 void no_motion(); 00089 00090 00091 00092 00093 00094 private: 00095 00097 quaternion current_q; 00099 quaternion d_q; 00100 00102 double disc_radius; 00103 00104 }; 00105 00106 } 00107 00108 #endif