llquaternion2.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. * @file llquaternion2.h
  3. * @brief LLQuaternion2 class header file - SIMD-enabled quaternion class
  4. *
  5. * $LicenseInfo:firstyear=2010&license=viewergpl$
  6. *
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_QUATERNION2_H
  33. #define LL_QUATERNION2_H
  34. /////////////////////////////
  35. // LLQuaternion2
  36. /////////////////////////////
  37. // This class stores a quaternion x*i + y*j + z*k + w in <x, y, z, w> order
  38. // (i.e., w in high order element of vector)
  39. //
  40. // These classes are intentionally minimal right now. If you need additional
  41. // functionality, please contact someone with SSE experience (e.g., Falcon or
  42. // Huseby).
  43. /////////////////////////////
  44. #include "llquaternion.h"
  45. class alignas(16) LLQuaternion2
  46. {
  47. public:
  48. LL_INLINE LLQuaternion2()
  49. {
  50. }
  51. explicit LLQuaternion2(const class LLQuaternion& quat);
  52. //////////////////////////
  53. // Get/Set
  54. //////////////////////////
  55. // Load from an LLQuaternion
  56. LL_INLINE void operator=(const LLQuaternion& quat)
  57. {
  58. mQ.loadua(quat.mQ);
  59. }
  60. // Return the internal LLVector4a representation of the quaternion
  61. LL_INLINE const LLVector4a& getVector4a() const;
  62. LL_INLINE LLVector4a& getVector4aRw();
  63. /////////////////////////
  64. // Quaternion modification
  65. /////////////////////////
  66. // Set this quaternion to the conjugate of src
  67. LL_INLINE void setConjugate(const LLQuaternion2& src);
  68. // Renormalizes the quaternion. Assumes it has nonzero length.
  69. LL_INLINE void normalize();
  70. // Quantize this quaternion to 8 bit precision
  71. LL_INLINE void quantize8();
  72. // Quantize this quaternion to 16 bit precision
  73. LL_INLINE void quantize16();
  74. LL_INLINE void mul(const LLQuaternion2& b);
  75. /////////////////////////
  76. // Quaternion inspection
  77. /////////////////////////
  78. // Return true if this quaternion is equal to 'rhs'.
  79. // Note! Quaternions exhibit "double-cover", so any rotation has two equally valid
  80. // quaternion representations and they will NOT compare equal.
  81. LL_INLINE bool equals(const LLQuaternion2& rhs, F32 tolerance = F_APPROXIMATELY_ZERO) const;
  82. // Return true if all components are finite and the quaternion is normalized
  83. LL_INLINE bool isOkRotation() const;
  84. protected:
  85. LLVector4a mQ;
  86. };
  87. #endif