OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NEON/Single/OgreArrayQuaternion.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __NEON_ArrayQuaternion_H__
29 #define __NEON_ArrayQuaternion_H__
30 
31 #ifndef __ArrayQuaternion_H__
32  #error "Don't include this file directly. include Math/Array/OgreArrayQuaternion.h"
33 #endif
34 
35 #include "OgreQuaternion.h"
36 
37 #include "Math/Array/OgreMathlib.h"
39 
40 #include "OgreArrayQuaternion.h"
41 
42 namespace Ogre
43 {
65  class _OgreExport ArrayQuaternion
66  {
67  public:
68  ArrayReal mChunkBase[4];
69 
71  ArrayQuaternion( const ArrayReal &chunkW, const ArrayReal &chunkX,
72  const ArrayReal &chunkY, const ArrayReal &chunkZ )
73  {
74  mChunkBase[0] = chunkW;
75  mChunkBase[1] = chunkX;
76  mChunkBase[2] = chunkY;
77  mChunkBase[3] = chunkZ;
78  }
79 
80  void getAsQuaternion( Quaternion &out, size_t index ) const
81  {
82  //Be careful of not writing to these regions or else strict aliasing rule gets broken!!!
83  const Real *aliasedReal = reinterpret_cast<const Real*>( mChunkBase );
84  out.w = aliasedReal[ARRAY_PACKED_REALS * 0 + index]; //W
85  out.x = aliasedReal[ARRAY_PACKED_REALS * 1 + index]; //X
86  out.y = aliasedReal[ARRAY_PACKED_REALS * 2 + index]; //Y
87  out.z = aliasedReal[ARRAY_PACKED_REALS * 3 + index]; //Z
88  }
89 
92  Quaternion getAsQuaternion( size_t index ) const
93  {
94  //Be careful of not writing to these regions or else strict aliasing rule gets broken!!!
95  const Real *aliasedReal = reinterpret_cast<const Real*>( mChunkBase );
96  return Quaternion( aliasedReal[ARRAY_PACKED_REALS * 0 + index], //W
97  aliasedReal[ARRAY_PACKED_REALS * 1 + index], //X
98  aliasedReal[ARRAY_PACKED_REALS * 2 + index], //Y
99  aliasedReal[ARRAY_PACKED_REALS * 3 + index] ); //Z
100  }
101 
102  void setFromQuaternion( const Quaternion &v, size_t index )
103  {
104  Real *aliasedReal = reinterpret_cast<Real*>( mChunkBase );
105  aliasedReal[ARRAY_PACKED_REALS * 0 + index] = v.w;
106  aliasedReal[ARRAY_PACKED_REALS * 1 + index] = v.x;
107  aliasedReal[ARRAY_PACKED_REALS * 2 + index] = v.y;
108  aliasedReal[ARRAY_PACKED_REALS * 3 + index] = v.z;
109  }
110 
111  void setAll( const Quaternion &v )
112  {
113  mChunkBase[0] = vdupq_n_f32( v.w );
114  mChunkBase[1] = vdupq_n_f32( v.x );
115  mChunkBase[2] = vdupq_n_f32( v.y );
116  mChunkBase[3] = vdupq_n_f32( v.z );
117  }
118 
120  inline void FromAngleAxis( const ArrayRadian& rfAngle, const ArrayVector3& rkAxis );
121 
123  inline void ToAngleAxis( ArrayRadian &rfAngle, ArrayVector3 &rkAxis ) const;
124 
125  inline friend ArrayQuaternion operator * ( const ArrayQuaternion &lhs, const ArrayQuaternion &rhs );
126 
127  inline friend ArrayQuaternion operator + ( const ArrayQuaternion &lhs, const ArrayQuaternion &rhs );
128  inline friend ArrayQuaternion operator - ( const ArrayQuaternion &lhs, const ArrayQuaternion &rhs );
129  inline friend ArrayQuaternion operator * ( const ArrayQuaternion &lhs, ArrayReal scalar );
130  inline friend ArrayQuaternion operator * ( ArrayReal scalar, const ArrayQuaternion &lhs );
131  inline void operator += ( const ArrayQuaternion &a );
132  inline void operator -= ( const ArrayQuaternion &a );
133  inline void operator *= ( const ArrayReal fScalar );
134 
136  inline ArrayVector3 xAxis( void ) const;
138  inline ArrayVector3 yAxis( void ) const;
140  inline ArrayVector3 zAxis( void ) const;
141 
143  inline ArrayReal Dot( const ArrayQuaternion& rkQ ) const;
144 
146  inline ArrayReal Norm( void ) const; //Returns the squared length, doesn't modify
147 
150  inline void normalise( void );
151 
152  inline ArrayQuaternion Inverse( void ) const; // apply to non-zero quaternion
153  inline ArrayQuaternion UnitInverse( void ) const; // apply to unit-length quaternion
154  inline ArrayQuaternion Exp( void ) const;
155  inline ArrayQuaternion Log( void ) const;
156 
158  inline ArrayVector3 operator * ( const ArrayVector3 &v ) const;
159 
178  static inline void mul( const ArrayQuaternion &inQ, ArrayVector3 &inOutVec );
179 
183  static inline ArrayQuaternion Slerp( ArrayReal fT, const ArrayQuaternion &rkP,
184  const ArrayQuaternion &rkQ );
185 
189  static inline ArrayQuaternion nlerpShortest( ArrayReal fT, const ArrayQuaternion& rkP,
190  const ArrayQuaternion& rkQ );
191 
195  static inline ArrayQuaternion nlerp( ArrayReal fT, const ArrayQuaternion& rkP,
196  const ArrayQuaternion& rkQ );
197 
218  inline void Cmov4( ArrayMaskR mask, const ArrayQuaternion &replacement );
219 
237  inline static ArrayQuaternion Cmov4( const ArrayQuaternion &arg1, const ArrayQuaternion &arg2, ArrayMaskR mask );
238 
239  static const ArrayQuaternion ZERO;
240  static const ArrayQuaternion IDENTITY;
241  };
245 }
246 
247 #include "OgreArrayQuaternion.inl"
248 
249 #endif
bool ArrayMaskR
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
void getAsQuaternion(Quaternion &out, size_t index) const
Real ArrayReal
void setFromQuaternion(const Quaternion &v, size_t index)
ArrayQuaternion(const ArrayReal &chunkW, const ArrayReal &chunkX, const ArrayReal &chunkY, const ArrayReal &chunkZ)
void setAll(const Quaternion &v)
Radian operator*(Real a, const Radian &b)
Definition: OgreMath.h:782
Quaternion getAsQuaternion(size_t index) const
Prefer using.
Implementation of a Quaternion, i.e.
Cache-friendly array of 3-dimensional represented as a SoA array.
#define ARRAY_PACKED_REALS
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:49
Cache-friendly array of Quaternion represented as a SoA array.