OpenStructure
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
stage
include
ost
geom
quat.hh
Go to the documentation of this file.
1
//------------------------------------------------------------------------------
2
// This file is part of the OpenStructure project <www.openstructure.org>
3
//
4
// Copyright (C) 2008-2011 by the OpenStructure authors
5
//
6
// This library is free software; you can redistribute it and/or modify it under
7
// the terms of the GNU Lesser General Public License as published by the Free
8
// Software Foundation; either version 3.0 of the License, or (at your option)
9
// any later version.
10
// This library is distributed in the hope that it will be useful, but WITHOUT
11
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
// details.
14
//
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with this library; if not, write to the Free Software Foundation, Inc.,
17
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
//------------------------------------------------------------------------------
19
#ifndef GEOM_QUAT_HH
20
#define GEOM_QUAT_HH
21
22
#include <iostream>
23
#include <boost/operators.hpp>
24
25
#include <
ost/geom/module_config.hh
>
26
27
/*
28
Unit Quaternion
29
30
math and code assembled from various places, among them:
31
32
E.B. Dam, M. Koch, M. Lillholm, Technical Report DIKU-TR-98/5,
33
Department of Computer Science, University of Copenhagen
34
35
boost quaternion example, (C) Copyright Hubert Holin 2001.
36
Distributed under the Boost Software License, Version 1.0.
37
38
Python Computer Graphics Kit, original code by Matthias Baas (C) 2004
39
Distributed under the GPL v2.0
40
*/
41
42
namespace
geom {
43
44
class
Mat3;
45
class
Vec3;
46
48
54
class
DLLEXPORT_OST_GEOM
Quat
:
55
private
boost::additive<Quat>,
56
private
boost::multiplicative<Quat, Real>,
57
private
boost::multiplicative<Quat,Quat>
58
{
59
public
:
60
Quat
();
61
62
Quat
(
Real
w,
Real
x,
Real
y,
Real
z);
63
64
// initialize with a rotation (in rad) around a given axis
65
Quat
(
Real
angle,
const
geom::Vec3
& axis);
66
67
// initialize from a rotation matrix
68
Quat
(
const
Mat3
& rotmat);
69
70
// return 3x3 rotation matrix
71
Mat3
ToRotationMatrix()
const
;
72
73
Vec3
GetAxis()
const
;
74
75
//get angle component
76
Real
GetAngle()
const
;
77
78
// operators
79
80
// negateable
81
Quat
operator-();
82
// addable
83
Quat
& operator+=(
const
Quat
& q);
84
// subtractable
85
Quat
& operator-=(
const
Quat
& q);
86
// multipliable with scalar
87
Quat
& operator*=(
Real
s);
88
// multipliable with other quat
89
Quat
& operator*=(
const
Quat
& q);
90
// dividable with scalar
91
Quat
& operator/=(
Real
s);
92
// dividable with other quat
93
Quat
& operator/=(
const
Quat
& q);
94
// comparable
95
bool
operator==
(
const
Quat
& q)
const
;
96
97
// Apply rotation to vector.
98
Vec3
Rotate
(
const
Vec3
& vec)
const
;
99
100
101
// these are public for direct value access
102
Real
w,x,y,
z
;
103
};
104
105
106
Quat
DLLEXPORT_OST_GEOM
Conjugate
(
const
Quat
& q);
107
108
// inner product
109
Real
DLLEXPORT_OST_GEOM
Dot
(
const
Quat
& q0,
const
Quat
& q1);
110
111
// spherical linear interpolation, with t in range [0,1]
112
Quat
DLLEXPORT_OST_GEOM
Slerp
(
const
Quat
& q0,
const
Quat
& q1,
Real
t);
113
114
Quat
DLLEXPORT_OST_GEOM
Inv
(
const
Quat
& q);
115
Quat
DLLEXPORT_OST_GEOM
Exp
(
const
Quat
& q);
116
Quat
DLLEXPORT_OST_GEOM
Log
(
const
Quat
& q);
117
118
Quat
DLLEXPORT_OST_GEOM
Grassmann
(
const
Quat
& lhs,
const
Quat
& rhs);
119
120
//normalize quaternion
121
Quat
DLLEXPORT_OST_GEOM
Normalize
(
const
Quat
& q);
122
123
DLLEXPORT_OST_GEOM
std::ostream&
operator<<
(std::ostream& str,
const
Quat
& q);
124
125
}
// ns
126
127
#endif
Generated on Thu Jun 14 2012 18:58:01 for OpenStructure by
1.8.1.1