PageRenderTime 50ms CodeModel.GetById 4ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmath/llquaternion2.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 105 lines | 24 code | 21 blank | 60 comment | 0 complexity | a3082ddec7b3e973b4f9def18cf89dad MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llquaternion2.h
  3. * @brief LLQuaternion2 class header file - SIMD-enabled quaternion class
  4. *
  5. * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_QUATERNION2_H
  27. #define LL_QUATERNION2_H
  28. /////////////////////////////
  29. // LLQuaternion2
  30. /////////////////////////////
  31. // This class stores a quaternion x*i + y*j + z*k + w in <x, y, z, w> order
  32. // (i.e., w in high order element of vector)
  33. /////////////////////////////
  34. /////////////////////////////
  35. // These classes are intentionally minimal right now. If you need additional
  36. // functionality, please contact someone with SSE experience (e.g., Falcon or
  37. // Huseby).
  38. /////////////////////////////
  39. #include "llquaternion.h"
  40. class LLQuaternion2
  41. {
  42. public:
  43. //////////////////////////
  44. // Ctors
  45. //////////////////////////
  46. // Ctor
  47. LLQuaternion2() {}
  48. // Ctor from LLQuaternion
  49. explicit LLQuaternion2( const class LLQuaternion& quat );
  50. //////////////////////////
  51. // Get/Set
  52. //////////////////////////
  53. // Load from an LLQuaternion
  54. inline void operator=( const LLQuaternion& quat )
  55. {
  56. mQ.loadua( quat.mQ );
  57. }
  58. // Return the internal LLVector4a representation of the quaternion
  59. inline const LLVector4a& getVector4a() const;
  60. inline LLVector4a& getVector4aRw();
  61. /////////////////////////
  62. // Quaternion modification
  63. /////////////////////////
  64. // Set this quaternion to the conjugate of src
  65. inline void setConjugate(const LLQuaternion2& src);
  66. // Renormalizes the quaternion. Assumes it has nonzero length.
  67. inline void normalize();
  68. // Quantize this quaternion to 8 bit precision
  69. inline void quantize8();
  70. // Quantize this quaternion to 16 bit precision
  71. inline void quantize16();
  72. /////////////////////////
  73. // Quaternion inspection
  74. /////////////////////////
  75. // Return true if this quaternion is equal to 'rhs'.
  76. // Note! Quaternions exhibit "double-cover", so any rotation has two equally valid
  77. // quaternion representations and they will NOT compare equal.
  78. inline bool equals(const LLQuaternion2& rhs, F32 tolerance = F_APPROXIMATELY_ZERO ) const;
  79. // Return true if all components are finite and the quaternion is normalized
  80. inline bool isOkRotation() const;
  81. protected:
  82. LLVector4a mQ;
  83. };
  84. #endif