/usr/include/mia-2.4/mia/3d/quaternion.hh is in libmia-2.4-dev 2.4.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | /* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_3d_quaternion_hh
#define mia_3d_quaternion_hh
#include <mia/3d/defines3d.hh>
#include <mia/3d/matrix.hh>
#include <mia/3d/vector.hh>
#include <ostream>
#include <cmath>
NS_MIA_BEGIN
/**
\ingroup misc
\brief a class to implement a quaternion
This class implements some operations of a quaternion.
The rotation is implemented as clockwise/left-handed rotation.
*/
class EXPORT_3D Quaternion {
public:
/**
The standard constructor that sets all values of the quaternion to zero.
*/
Quaternion();
/**
The copy constructor.
\param other
*/
Quaternion(const Quaternion& other) = default;
/**
This constructor creates a quaternion from three Euler angles that are applied
with the <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Conversion_between_quaternions_and_Euler_angles">x-y-z convention</a>.
\param rot
*/
Quaternion(const C3DDVector& rot);
/**
This constructor creates a quaternion from a 3x3 rotation matrix.
If mat3x3 is not a true rotation matrix, then this constructor evaluates the
rotation quaternion that best resembles the matrix transformation.
\param rot
*/
Quaternion(const C3DFMatrix& rot);
/**
This constructor creates a quaternion from a 3x3 rotation matrix.
If mat3x3 is not a true rotation matrix, then this constructor evaluates the
rotation quaternion that best resembles the matrix transformation.
\param rot
*/
Quaternion(const C3DDMatrix& rot);
/**
Constructor to create a quaternion by directly setting its elements.
*/
Quaternion(double w, double x, double y, double z);
/**
\param a
\param b
\returns true if the quaternions are element-wise equal
*/
friend bool operator == (const Quaternion& a, const Quaternion& b);
/// \returns the norm of the quaternion
double norm() const;
/// normalizes to quaternion
void normalize();
/// \returns the inverse of the quaternion assuming it is normalized
Quaternion inverse() const;
/// \returns the Euler angles that correspond to the rotation described by this quaternion
C3DDVector get_euler_angles() const;
/**
in-place adding
\param other
\returns reference to the updated quaternion
*/
Quaternion& operator += (const Quaternion& other);
/**
in-place substraction
\param other
\returns reference to the updated quaternion
*/
Quaternion& operator -= (const Quaternion& other);
/**
in-place multiplication
\param other
\returns reference to the updated quaternion
*/
Quaternion& operator *= (const Quaternion& other);
/**
Print the quaternion to an output stream
\param os the output stream
*/
void print(std::ostream& os) const;
/// \returns the w- or $x_0$ component of the quaternion
double w() const;
/// \returns the x- or $x_1$ component of the quaternion
double x() const;
/// \returns the y- or $x_2$ component of the quaternion
double y() const;
/// \returns the z- or $x_3$ component of the quaternion
double z() const;
const C3DDMatrix get_rotation_matrix() const;
static const Quaternion _1;
private:
C3DDVector m_v;
double m_w;
};
bool EXPORT_3D operator == (const Quaternion& a, const Quaternion& b);
bool EXPORT_3D operator != (const Quaternion& a, const Quaternion& b);
inline double Quaternion::w() const
{
return m_w;
}
inline double Quaternion::x() const
{
return m_v.x;
}
inline double Quaternion::y() const
{
return m_v.y;
}
inline double Quaternion::z() const
{
return m_v.z;
}
inline std::ostream& operator << (std::ostream& os, const Quaternion& a)
{
a.print(os);
return os;
}
EXPORT_3D std::istream& operator >> (std::istream& os, Quaternion& a);
NS_MIA_END
#endif
|