Marble

Quaternion.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2004-2007 Torsten Rahn <[email protected]>
4 // SPDX-FileCopyrightText: 2007 Inge Wallin <[email protected]>
5 // SPDX-FileCopyrightText: 2011 Bernhard Beschow <[email protected]>
6 // SPDX-FileCopyrightText: 2014 Dennis Nienhüser <[email protected]>
7 //
8 
9 //
10 // Quaternions provides a class that deals with quaternion operations.
11 
12 // krazy:excludeall=dpointer,inline
13 
14 #ifndef MARBLE_QUATERNION_H
15 #define MARBLE_QUATERNION_H
16 
17 #include "marble_export.h"
18 #include <cmath>
19 #include <QtGlobal>
20 
21 namespace Marble
22 {
23 
24 enum
25 {
26  Q_X = 0,
27  Q_Y = 1,
28  Q_Z = 2,
29  Q_W = 3
30 };
31 
32 
33 typedef qreal xmmfloat[4];
34 typedef xmmfloat matrix[3];
35 
36 
37 class MARBLE_EXPORT Quaternion
38 {
39  public:
40  Quaternion();
41  Quaternion(qreal w, qreal x, qreal y, qreal z);
42 
43  /*!\brief used to generate Quaternion from longitude and latitude
44  *
45  * \param lon longitude
46  * \param lat latitude
47  */
48  static Quaternion fromSpherical(qreal lon, qreal lat);
49  static Quaternion fromEuler(qreal pitch, qreal yaw, qreal roll);
50 
51  static Quaternion slerp(const Quaternion &q1, const Quaternion &q2, qreal t);
52  static Quaternion nlerp(const Quaternion &q1, const Quaternion &q2, qreal t);
53 
54  // Operators
55  Quaternion operator*(const Quaternion &q) const;
56  Quaternion operator+(const Quaternion &q) const;
57  Quaternion operator*(qreal factor) const;
58  bool operator==(const Quaternion &q) const;
59  Quaternion& operator*=(const Quaternion &q);
60  Quaternion& operator*=(qreal);
61 
62  void getSpherical(qreal &lon, qreal &lat) const;
63 
64  void normalize();
65 
66  qreal length() const;
67 
68  Quaternion inverse() const;
69  Quaternion log() const;
70  Quaternion exp() const;
71 
72  qreal pitch() const;
73  qreal yaw() const;
74  qreal roll() const;
75 
76 
77  void rotateAroundAxis(const Quaternion &q);
78 
79  void toMatrix(matrix &m) const;
80  void rotateAroundAxis(const matrix &m);
81 
82  // TODO: Better add accessors...
83  xmmfloat v;
84 };
85 
86 }
87 
88 #ifndef QT_NO_DEBUG_STREAM
89 MARBLE_EXPORT QDebug operator<<(QDebug, const Marble::Quaternion &);
90 #endif
91 
92 #endif // MARBLE_QUATERNION_H
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
QString normalize(QStringView str)
QAction * roll(const QObject *recvr, const char *slot, QObject *parent)
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
const QCA_EXPORT SecureArray operator+(const SecureArray &a, const SecureArray &b)
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat May 21 2022 04:08:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.