quaternion.hh
Go to the documentation of this file.
/* -*- 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
class EXPORT_3D Quaternion
{
public:
Quaternion();
Quaternion(const Quaternion& other) = default;
Quaternion(const C3DDVector& rot);
Quaternion(const C3DFMatrix& rot);
Quaternion(const C3DDMatrix& rot);
Quaternion(double w, double x, double y, double z);
friend bool operator == (const Quaternion& a, const Quaternion& b);
double norm() const;
void normalize();
Quaternion inverse() const;
C3DDVector get_euler_angles() const;
Quaternion& operator += (const Quaternion& other);
Quaternion& operator -= (const Quaternion& other);
Quaternion& operator *= (const Quaternion& other);
void print(std::ostream& os) const;
double w() const;
double x() const;
double y() const;
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
operator+=
EXPORT_2D C2DFVectorfield & operator+=(C2DFVectorfield &a, const C2DFVectorfield &b)
matrix.hh
C3DFMatrix
T3DMatrix< float > C3DFMatrix
a simple 3x3 matrix with single precision floating point values
Definition 3d/matrix.hh:226
C3DDMatrix
T3DMatrix< double > C3DDMatrix
a simple 3x3 matrix with double precision floating point values
Definition 3d/matrix.hh:229
vector.hh
C3DDVector
T3DVector< double > C3DDVector
A double 3D Vector.
Definition 3d/vector.hh:412
operator==
bool operator==(const CAttribute &a, const CAttribute &b)
Definition attributes.hh:95
Quaternion
a class to implement a quaternion
Definition quaternion.hh:44
Quaternion::Quaternion
Quaternion(const Quaternion &other)=default
Quaternion::norm
double norm() const
Quaternion::x
double x() const
Definition quaternion.hh:165
Quaternion::get_rotation_matrix
const C3DDMatrix get_rotation_matrix() const
Quaternion::Quaternion
Quaternion(const C3DFMatrix &rot)
Quaternion::inverse
Quaternion inverse() const
Quaternion::Quaternion
Quaternion(double w, double x, double y, double z)
Quaternion::normalize
void normalize()
normalizes to quaternion
Quaternion::z
double z() const
Definition quaternion.hh:175
Quaternion::w
double w() const
Definition quaternion.hh:160
Quaternion::_1
static const Quaternion _1
Definition quaternion.hh:149
Quaternion::print
void print(std::ostream &os) const
Quaternion::Quaternion
Quaternion(const C3DDMatrix &rot)
Quaternion::Quaternion
Quaternion()
Quaternion::get_euler_angles
C3DDVector get_euler_angles() const
Quaternion::y
double y() const
Definition quaternion.hh:170
Quaternion::Quaternion
Quaternion(const C3DDVector &rot)
defines3d.hh
EXPORT_3D
#define EXPORT_3D
Definition defines3d.hh:45
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
operator==
bool EXPORT_3D operator==(const Quaternion &a, const Quaternion &b)
operator!=
bool EXPORT_3D operator!=(const Quaternion &a, const Quaternion &b)
operator>>
EXPORT_3D std::istream & operator>>(std::istream &os, Quaternion &a)
operator<<
std::ostream & operator<<(std::ostream &os, const Quaternion &a)
Definition quaternion.hh:182