zenilib: zenilib/jni/external/zenilib/zeni/Zeni/Quaternion.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Quaternion.h
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2 * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3 *
4 * zenilib is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * zenilib is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16 */
17
33 #ifndef ZENI_QUATERNION_H
34 #define ZENI_QUATERNION_H
35
36 #include <Zeni/Serialization.h>
37 #include <Zeni/String.h>
38 #include <Zeni/Matrix4f.h>
39
40 #include <Zeni/Define.h>
41
42 namespace Zeni {
43
44 struct ZENI_DLL Quaternion {
45 inline explicit Quaternion(const bool &degenerate_ = false);
46 Quaternion(const float &time, const Vector3f &space, const bool &degenerate_ = false);
47 Quaternion(const float &yaw, const float &pitch, const float &roll, const bool &degenerate_ = false);
48 Quaternion(const Quaternion &rhs, const bool &degenerate_ = false);
49
51 static Quaternion Axis_Angle(const Vector3f &v, const float &theta);
53 static Quaternion Vector3f_to_Vector3f(const Vector3f &destination, const Vector3f &source);
55 static Quaternion Forward_Up(const Vector3f &destination_forward,
56 const Vector3f &destination_up,
57 const Vector3f &default_forward = ZENI_DEFAULT_FORWARD_VECTOR,
58 const Vector3f &default_up = ZENI_DEFAULT_UP_VECTOR);
59
60 // Vector addition/subtraction
61 inline Quaternion operator+(const Quaternion &rhs) const;
62 inline Quaternion operator-(const Quaternion &rhs) const;
63 inline Quaternion & operator+=(const Quaternion &rhs);
64 inline Quaternion & operator-=(const Quaternion &rhs);
65
66 // Vector Dot-Product and Cross-Product
67 inline Quaternion operator*(const Quaternion &rhs) const;
68 inline Quaternion operator*=(const Quaternion &rhs);
69 inline Quaternion grassman_product(const Quaternion &rhs) const;
70 inline Quaternion grassman_even_product(const Quaternion &rhs) const;
71 inline Quaternion grassman_odd_product(const Quaternion &rhs) const;
72 inline Quaternion euclidean_product(const Quaternion &rhs) const;
73 inline Quaternion euclidean_even_product(const Quaternion &rhs) const;
74 inline Quaternion euclidean_odd_product(const Quaternion &rhs) const;
75
76 // Vector Scalar Multiplication I of II
77 inline Quaternion operator*(const float &rhs) const;
78 inline Quaternion operator/(const float &rhs) const;
79 inline Quaternion & operator*=(const float &rhs);
80 inline Quaternion & operator/=(const float &rhs);
81 inline Quaternion operator-() const;
82
83 // Other Standard Functions
84 Quaternion & normalize();
85 Quaternion normalized() const;
86 inline float magnitude2() const;
87 inline float magnitude() const;
88 inline Quaternion conjugate() const;
89 inline Quaternion reciprocal() const;
90 inline Quaternion absolute_value() const;
91 inline Quaternion norm() const;
92 inline Quaternion determinant() const;
93 inline Quaternion adjoint() const;
94
95 // Useful interops
96 inline Vector3f operator*(const Vector3f &rhs) const;
97 inline std::pair<Vector3f, float> get_rotation() const;
98 inline Matrix4f get_matrix() const;
99
100 // Indexing
101 inline const float & operator[](const int &index) const;
102 inline float & operator[](const int &index);
103
104 float time;
105 Vector3f space;
106
107 bool degenerate;
108 };
109
110 inline Quaternion operator*(const float &lhs, const Quaternion &rhs) {
111 return rhs * lhs;
112 }
113
114 inline Quaternion operator/(const float &lhs, const Quaternion &rhs) {
115 return rhs * lhs;
116 }
117
118 ZENI_DLL std::ostream & serialize(std::ostream &os, const Quaternion &value);
119 ZENI_DLL std::istream & unserialize(std::istream &is, Quaternion &value);
120
121 }
122
123 #include <Zeni/Undefine.h>
124
125 #endif
Zeni::Quaternion::time
float time
Definition: Quaternion.h:104
Zeni::Quaternion::degenerate
bool degenerate
Definition: Quaternion.h:107
normalized
GLint GLenum GLboolean normalized
Definition: glew.h:1891
Zeni::Quaternion::space
Vector3f space
Definition: Quaternion.h:105
operator+
TiXmlString operator+(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.cpp:86
Zeni::operator/
Quaternion operator/(const float &lhs, const Quaternion &rhs)
Definition: Quaternion.h:114
Zeni::unserialize
std::istream & unserialize(std::istream &is, Color &value)
Definition: Color.cpp:72
Zeni::serialize
std::ostream & serialize(std::ostream &os, const Color &value)
Definition: Color.cpp:68
Undefine.h
Zeni::Vector3f
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
v
const GLdouble * v
Definition: glew.h:1377
Define.h
Matrix4f.h
Serialization.h
Zeni::Quaternion
A Featureful Quaternion Class.
Definition: Quaternion.h:44
index
GLuint index
Definition: glew.h:1800
Zeni::operator*
Quaternion operator*(const float &lhs, const Quaternion &rhs)
Definition: Quaternion.h:110
value
EGLSurface EGLint void ** value
Definition: eglext.h:301
String.h
Zeni::Matrix4f
A Featureful 4-Space Matrix Class.
Definition: Matrix4f.h:47
source
GLsizei GLsizei GLchar * source
Definition: gl2ext.h:994
ZENI_DEFAULT_UP_VECTOR
#define ZENI_DEFAULT_UP_VECTOR
Definition: Define.h:33
ZENI_DEFAULT_FORWARD_VECTOR
#define ZENI_DEFAULT_FORWARD_VECTOR
Definition: Define.h:32