ESyS-Particle  2.3.2
Quaternion.h
Go to the documentation of this file.
1 
2 // //
3 // Copyright (c) 2003-2014 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 #ifndef _QUATERNION_H
14 #define _QUATERNION_H
15 
16 #define DO_INLINE_QUATERNION 1
17 
18 #if DO_INLINE_QUATERNION >= 1
19 #define QUATERNION_INLINE inline
20 #else
21 #define QUATERNION_INLINE
22 #endif
23 
24 #include <math.h>
25 #include "Foundation/vec3.h"
26 
27 class Matrix3;
28 
30 {
31 private:
33  double scalar;
34 
35 public:
36  // Constructors
38  QUATERNION_INLINE Quaternion(double, const Vec3 &);
39 
40  // Copy Constructor
42 
43  // Destructor
45 
46  // Assignment
48 
49  // Output
50  QUATERNION_INLINE std::ostream& output(std::ostream&) const;
51  QUATERNION_INLINE std::istream& input(std::istream& ci);
52 
53  // Math
54  QUATERNION_INLINE bool operator==(const Quaternion&) const;
55  QUATERNION_INLINE bool operator!=(const Quaternion&) const;
56 
60  QUATERNION_INLINE friend Quaternion operator*(double, const Quaternion&);
64 
70 
72 
74 
75  QUATERNION_INLINE double length() const;
76 
78 
79  // Access Functions
80  QUATERNION_INLINE Vec3 return_vec() const { return vector; };
81  QUATERNION_INLINE double return_sca() const { return scalar; };
82 
83  QUATERNION_INLINE void set_vector(const Vec3 &v) { vector = v; }
84  QUATERNION_INLINE void set_scalar(double d) { scalar = d; }
85 
92 
96  typedef std::pair<double,Vec3> AngleAxisPair;
103 };
104 
105 QUATERNION_INLINE std::ostream& operator<<(std::ostream&, const Quaternion &);
106 QUATERNION_INLINE std::istream& operator>>(std::istream&, Quaternion &);
107 
108 #if DO_INLINE_QUATERNION >= 1
109 #include "Foundation/Quaternion.hpp"
110 #endif
111 
112 #endif