quaternion.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2013 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef mia_3d_quaternion_hh
22 #define mia_3d_quaternion_hh
23 
24 #include <ostream>
25 #include <mia/3d/defines3d.hh>
26 #include <mia/3d/vector.hh>
27 
28 
30 
39 
40 public:
44  Quaternion();
45 
50  Quaternion(const Quaternion& other) = default;
51 
57  Quaternion(const C3DDVector& rot);
58 
62  Quaternion(double w, double x, double y, double z);
63 
70  friend bool operator == (const Quaternion& a, const Quaternion& b);
71 
73  double norm() const;
74 
76  void normalize();
77 
79  Quaternion inverse() const;
80 
82  C3DDVector get_euler_angles() const;
83 
89  Quaternion& operator += (const Quaternion& other);
90 
96  Quaternion& operator -= (const Quaternion& other);
97 
104  Quaternion& operator *= (const Quaternion& other);
105 
110  void print(std::ostream& os) const;
111 
113  double w() const;
114 
116  double x() const;
117 
119  double y() const;
120 
122  double z() const;
123 
124 private:
125  C3DDVector m_v;
126  double m_w;
127 };
128 
129 
130 bool EXPORT_3D operator == (const Quaternion& a, const Quaternion& b);
131 bool EXPORT_3D operator != (const Quaternion& a, const Quaternion& b);
132 
133 
134 
135 
136 inline double Quaternion::w() const
137 {
138  return m_w;
139 }
140 
141 inline double Quaternion::x() const
142 {
143  return m_v.x;
144 }
145 
146 inline double Quaternion::y() const
147 {
148  return m_v.y;
149 }
150 
151 inline double Quaternion::z() const
152 {
153  return m_v.z;
154 }
155 
156 
157 
158 inline std::ostream& operator << (std::ostream& os, const Quaternion& a)
159 {
160  a.print(os);
161  return os;
162 }
163 
165 
166 #endif
a class to implement a quaternion
Definition: quaternion.hh:38
bool EXPORT_3D operator!=(const Quaternion &a, const Quaternion &b)
double z() const
Definition: quaternion.hh:151
T z
vector element
Definition: 3d/vector.hh:53
void print(std::ostream &os) const
double w() const
Definition: quaternion.hh:136
std::shared_ptr< Image > normalize(const Image &image)
a normalizer for image intensities
Definition: normalize.hh:131
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:43
EXPORT_2D C2DFVectorfield & operator+=(C2DFVectorfield &a, const C2DFVectorfield &b)
#define EXPORT_3D
Definition: defines3d.hh:44
double x() const
Definition: quaternion.hh:141
T y
vector element
Definition: 3d/vector.hh:51
double y() const
Definition: quaternion.hh:146
std::ostream & operator<<(std::ostream &os, const Quaternion &a)
Definition: quaternion.hh:158
bool EXPORT_3D operator==(const Quaternion &a, const Quaternion &b)
T x
vector element
Definition: 3d/vector.hh:49
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:46