Marble

Quaternion.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2004-2007 Torsten Rahn <tackat@kde.org>
4// SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
5// SPDX-FileCopyrightText: 2011 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
6// SPDX-FileCopyrightText: 2014 Dennis Nienhüser <nienhueser@kde.org>
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
21namespace Marble
22{
23
24enum
25{
26 Q_X = 0,
27 Q_Y = 1,
28 Q_Z = 2,
29 Q_W = 3
30};
31
32
33typedef qreal xmmfloat[4];
34typedef xmmfloat matrix[3];
35
36
37class 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
89MARBLE_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 &)
QAction * roll(const QObject *recvr, const char *slot, QObject *parent)
QString normalize(QStringView str)
Binds a QML item to a specific geodetic location in screen coordinates.
QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &b)
bool operator==(const QGraphicsApiFilter &reference, const QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:57:57 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.