GraphicsAPI_2020C
quaternion.h
Go to the documentation of this file.
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
4 
5 Copyright (c) 2006-2017, assimp team
6 
7 All rights reserved.
8 
9 Redistribution and use of this software in source and binary forms,
10 with or without modification, are permitted provided that the
11 following conditions are met:
12 
13 * Redistributions of source code must retain the above
14  copyright notice, this list of conditions and the
15  following disclaimer.
16 
17 * Redistributions in binary form must reproduce the above
18  copyright notice, this list of conditions and the
19  following disclaimer in the documentation and/or other
20  materials provided with the distribution.
21 
22 * Neither the name of the assimp team, nor the names of its
23  contributors may be used to endorse or promote products
24  derived from this software without specific prior
25  written permission of the assimp team.
26 
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 
39 ----------------------------------------------------------------------
40 */
41 
45 #pragma once
46 #ifndef AI_QUATERNION_H_INC
47 #define AI_QUATERNION_H_INC
48 
49 #ifdef __cplusplus
50 
51 #include "defs.h"
52 
53 template <typename TReal> class aiVector3t;
54 template <typename TReal> class aiMatrix3x3t;
55 
56 // ---------------------------------------------------------------------------
58 template <typename TReal>
59 class aiQuaterniont
60 {
61 public:
62  aiQuaterniont() : w(1.0), x(), y(), z() {}
63  aiQuaterniont(TReal pw, TReal px, TReal py, TReal pz)
64  : w(pw), x(px), y(py), z(pz) {}
65 
67  explicit aiQuaterniont( const aiMatrix3x3t<TReal>& pRotMatrix);
68 
70  aiQuaterniont( TReal rotx, TReal roty, TReal rotz);
71 
73  aiQuaterniont( aiVector3t<TReal> axis, TReal angle);
74 
76  explicit aiQuaterniont( aiVector3t<TReal> normalized);
77 
79  aiMatrix3x3t<TReal> GetMatrix() const;
80 
81 public:
82 
83  bool operator== (const aiQuaterniont& o) const;
84  bool operator!= (const aiQuaterniont& o) const;
85 
86  bool Equal(const aiQuaterniont& o, TReal epsilon = 1e-6) const;
87 
88 public:
89 
91  aiQuaterniont& Normalize();
92 
94  aiQuaterniont& Conjugate ();
95 
97  aiVector3t<TReal> Rotate (const aiVector3t<TReal>& in);
98 
100  aiQuaterniont operator* (const aiQuaterniont& two) const;
101 
102 public:
103 
110  static void Interpolate( aiQuaterniont& pOut, const aiQuaterniont& pStart,
111  const aiQuaterniont& pEnd, TReal pFactor);
112 
113 public:
114 
116  TReal w, x, y, z;
117 } ;
118 
119 typedef aiQuaterniont<ai_real> aiQuaternion;
120 
121 #else
122 
123 struct aiQuaternion {
124  ai_real w, x, y, z;
125 };
126 
127 #endif
128 
129 #endif // AI_QUATERNION_H_INC
GLM_FUNC_DECL T angle(qua< T, Q > const &x)
Returns the quaternion rotation angle.
Definition: quaternion_trigonometric.inl:6
Definition: quaternion.h:123
Assimp build configuration setup.
GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon()
Return the epsilon constant for floating point types.
Definition: scalar_constants.inl:6
GLM_FUNC_DECL GLM_CONSTEXPR genType e()
Return e constant.
Definition: constants.inl:102
GLM_FUNC_DECL vec< 3, T, Q > axis(qua< T, Q > const &x)
Returns the q rotation axis.
Definition: quaternion_trigonometric.inl:17