Marble

Quaternion.h
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2004-2007 Torsten Rahn <[email protected]>
9 // Copyright 2007 Inge Wallin <[email protected]>
10 // Copyright 2011 Bernhard Beschow <[email protected]>
11 // Copyright 2014 Dennis Nienhüser <[email protected]>
12 //
13 
14 //
15 // Quaternions provides a class that deals with quaternion operations.
16 
17 // krazy:excludeall=dpointer,inline
18 
19 #ifndef MARBLE_QUATERNION_H
20 #define MARBLE_QUATERNION_H
21 
22 #include "marble_export.h"
23 #include <cmath>
24 #include <QtGlobal>
25 
26 namespace Marble
27 {
28 
29 enum
30 {
31  Q_X = 0,
32  Q_Y = 1,
33  Q_Z = 2,
34  Q_W = 3
35 };
36 
37 
38 typedef qreal xmmfloat[4];
39 typedef xmmfloat matrix[3];
40 
41 
42 class MARBLE_EXPORT Quaternion
43 {
44  public:
45  Quaternion();
46  Quaternion(qreal w, qreal x, qreal y, qreal z);
47 
53  static Quaternion fromSpherical(qreal lon, qreal lat);
54  static Quaternion fromEuler(qreal pitch, qreal yaw, qreal roll);
55 
56  static Quaternion slerp(const Quaternion &q1, const Quaternion &q2, qreal t);
57  static Quaternion nlerp(const Quaternion &q1, const Quaternion &q2, qreal t);
58 
59  // Operators
60  Quaternion operator*(const Quaternion &q) const;
61  Quaternion operator+(const Quaternion &q) const;
62  Quaternion operator*(qreal factor) const;
63  bool operator==(const Quaternion &q) const;
64  Quaternion& operator*=(const Quaternion &q);
65  Quaternion& operator*=(qreal);
66 
67  void getSpherical(qreal &lon, qreal &lat) const;
68 
69  void normalize();
70 
71  qreal length() const;
72 
73  Quaternion inverse() const;
74  Quaternion log() const;
75  Quaternion exp() const;
76 
77  qreal pitch() const;
78  qreal yaw() const;
79  qreal roll() const;
80 
81 
82  void rotateAroundAxis(const Quaternion &q);
83 
84  void toMatrix(matrix &m) const;
85  void rotateAroundAxis(const matrix &m);
86 
87  // TODO: Better add accessors...
88  xmmfloat v;
89 };
90 
91 }
92 
93 #ifndef QT_NO_DEBUG_STREAM
94 MARBLE_EXPORT QDebug operator<<(QDebug, const Marble::Quaternion &);
95 #endif
96 
97 #endif // MARBLE_QUATERNION_H
QChar normalize(QChar c)
Binds a QML item to a specific geodetic location in screen coordinates.
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
KDEGAMES_EXPORT QAction * roll(const QObject *recvr, const char *slot, QObject *parent)
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &b)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Sep 17 2020 23:19:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.