MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Quarternion.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 #ifndef QUARTERNION_H
26 #define QUARTERNION_H
27 
28 #include "Vector.h"
29 #include "Matrix.h"
30 #include "ExtendedMath.h"
31 
37 {
38 public:
42  Quarternion();
43 
47  Quarternion(const Quarternion& other);
48 
52  Quarternion(double x, double y, double z, double w);
53 
57  Quarternion(Vec3D axis, double angle);
58 
62  void getAxisAndAngle(Vec3D& axis, double& angle) const;
63 
68 
72  void reset();
73 
77  void normalise();
78 
82  Quarternion operator *(const Quarternion &other) const;
83 
87  void integrate(const Vec3D& omega, double timeStep);
88 
93  Quarternion(const Vec3D& a);
94 
98  Vec3D get3DAngles() const;
99 
103  friend std::ostream& operator<<(std::ostream& os, const Quarternion &q);
104 
108  friend std::istream& operator>>(std::istream& is, Quarternion &q);
109 
110 private:
115 };
116 
117 #endif
Mdouble z_
Definition: Quarternion.h:114
void getAxisAndAngle(Vec3D &axis, double &angle) const
Returns the orientation as represented by a rotation around an axis.
Definition: Quarternion.cc:71
Vec3D get3DAngles() const
Constructs a representation of the quarternion using 3 rotations in the lab x-y-z sequence...
Definition: Quarternion.cc:143
double Mdouble
friend std::istream & operator>>(std::istream &is, Quarternion &q)
Definition: Quarternion.cc:179
void reset()
Resets a the Quarternion.
Definition: Quarternion.cc:91
Quarternion operator*(const Quarternion &other) const
Multiplication operator.
Definition: Quarternion.cc:108
friend std::ostream & operator<<(std::ostream &os, const Quarternion &q)
Definition: Quarternion.cc:173
Mdouble y_
Definition: Quarternion.h:114
Mdouble x_
Definition: Quarternion.h:114
Quarternion()
Constructs a basic Quarternion.
Definition: Quarternion.cc:32
Mdouble w_
Definition: Quarternion.h:114
Matrix3D getRotationMatrix() const
Definition: Quarternion.cc:77
Implementation of a 3D matrix.
Definition: Matrix.h:36
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
void normalise()
Normalises the Quarternion.
Definition: Quarternion.cc:99
void integrate(const Vec3D &omega, double timeStep)
Integration of the Quarternion using rotational velocity and timestep.
Definition: Quarternion.cc:118