MCL
A C++ library mirroring some of the most common Matlab functions.
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
mcl
include
quaternion.h
Go to the documentation of this file.
1
/*
2
MCL
3
Copyright (c) 2012-18, Enzo De Sena
4
All rights reserved.
5
6
Authors: Enzo De Sena, enzodesena@gmail.com
7
*/
8
9
// This file contains definitions of matrix operations and classes
10
11
#ifndef MCL_QUATERNION_H
12
#define MCL_QUATERNION_H
13
14
#include "
mcltypes.h
"
15
#include "
point.h
"
16
#include "
constants.h
"
17
#include <cassert>
18
19
namespace
mcl {
20
21
23
enum
EulerOrder
{
24
zxz
,
xyx
,
yzy
,
zyz
,
xzx
,
yxy
,
25
xyz
,
yzx
,
zxy
,
xzy
,
zyx
,
yxz
26
};
27
28
struct
AxAng
{
29
Real
x
;
30
Real
y
;
31
Real
z
;
32
Real
angle
;
33
};
34
36
class
Quaternion
{
37
public
:
40
Quaternion
(
const
Real
w
,
const
Real
x
,
const
Real
y
,
const
Real
z
) noexcept :
41
w_(
w
), x_(
x
), y_(
y
), z_(
z
) {}
42
43
Real
w
() const noexcept {
return
w_; }
44
Real
x
() const noexcept {
return
x_; }
45
Real
y
() const noexcept {
return
y_; }
46
Real
z
() const noexcept {
return
z_; }
47
50
static
Quaternion
Identity
();
51
52
static
bool
Test
();
53
54
private
:
55
// q = w + x*i + y*j + z*k where i² = j² = k² = i*j*k = -1
56
Real
w_;
57
Real
x_;
58
Real
y_;
59
Real
z_;
60
};
61
63
Quaternion
AxAng2Quat
(
const
Real
x,
const
Real
y,
const
Real
z,
64
const
Real
angle) noexcept;
65
66
AxAng
Quat2AxAng
(
const
Quaternion& q) noexcept;
67
68
Quaternion
QuatConj
(
const
Quaternion& q) noexcept;
69
72
Real
Norm
(
const
Quaternion& q) noexcept;
73
74
Point
QuatRotate
(
const
Quaternion& q,
const
Point
& r,
75
const
Handedness
handedness =
kRightHanded
) noexcept;
76
78
Quaternion
QuatMultiply
(const Quaternion& q, const Quaternion& r) noexcept;
79
85
Quaternion
Eul2Quat
(const
Real
angle_1, const
Real
angle_2, const
Real
angle_3,
86
const
EulerOrder
order =
zyx
) noexcept;
87
90
Real
Quat2EulX
(const Quaternion q,
91
const
EulerOrder
order =
zyx
) noexcept;
92
95
Real
Quat2EulY
(const Quaternion q,
96
const
EulerOrder
order =
zyx
) noexcept;
97
100
Real
Quat2EulZ
(const Quaternion q,
101
const
EulerOrder
order =
zyx
) noexcept;
102
103
Quaternion
QuatInverse
(const Quaternion q) noexcept;
104
105
}
// namespace mcl
106
107
#endif
Generated on Mon Mar 30 2020 09:25:16 for MCL by
1.8.2