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 <QtGlobal>
19#include <cmath>
20
21namespace Marble
22{
23
24enum {
25 Q_X = 0,
26 Q_Y = 1,
27 Q_Z = 2,
28 Q_W = 3
29};
30
31typedef qreal xmmfloat[4];
32typedef xmmfloat matrix[3];
33
34class MARBLE_EXPORT Quaternion
35{
36public:
37 Quaternion();
38 Quaternion(qreal w, qreal x, qreal y, qreal z);
39
40 /*!\brief used to generate Quaternion from longitude and latitude
41 *
42 * \param lon longitude
43 * \param lat latitude
44 */
45 static Quaternion fromSpherical(qreal lon, qreal lat);
46 static Quaternion fromEuler(qreal pitch, qreal yaw, qreal roll);
47
48 static Quaternion slerp(const Quaternion &q1, const Quaternion &q2, qreal t);
49 static Quaternion nlerp(const Quaternion &q1, const Quaternion &q2, qreal t);
50
51 // Operators
52 Quaternion operator*(const Quaternion &q) const;
53 Quaternion operator+(const Quaternion &q) const;
54 Quaternion operator*(qreal factor) const;
55 bool operator==(const Quaternion &q) const;
56 Quaternion &operator*=(const Quaternion &q);
57 Quaternion &operator*=(qreal);
58
59 void getSpherical(qreal &lon, qreal &lat) const;
60
61 void normalize();
62
63 qreal length() const;
64
65 Quaternion inverse() const;
66 Quaternion log() const;
67 Quaternion exp() const;
68
69 qreal pitch() const;
70 qreal yaw() const;
71 qreal roll() const;
72
73 void rotateAroundAxis(const Quaternion &q);
74
75 void toMatrix(matrix &m) const;
76 void rotateAroundAxis(const matrix &m);
77
78 // TODO: Better add accessors...
79 xmmfloat v;
80};
81
82}
83
84#ifndef QT_NO_DEBUG_STREAM
85MARBLE_EXPORT QDebug operator<<(QDebug, const Marble::Quaternion &);
86#endif
87
88#endif // MARBLE_QUATERNION_H
QDebug operator<<(QDebug dbg, const DcrawInfoContainer &c)
QAction * roll(const QObject *recvr, const char *slot, QObject *parent)
QString normalize(QStringView str)
bool operator==(const StyleDelim &l, const StyleDelim &r)
Binds a QML item to a specific geodetic location in screen coordinates.
QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &b)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.