PageRenderTime 141ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmath/llmatrix3a.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 128 lines | 30 code | 29 blank | 69 comment | 0 complexity | e0aadc2624b7e8dd9ce359c449caefae MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llmatrix3a.h
  3. * @brief LLMatrix3a class header file - memory aligned and vectorized 3x3 matrix
  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_LLMATRIX3A_H
  27. #define LL_LLMATRIX3A_H
  28. /////////////////////////////
  29. // LLMatrix3a, LLRotation
  30. /////////////////////////////
  31. // This class stores a 3x3 (technically 4x3) matrix in column-major order
  32. /////////////////////////////
  33. /////////////////////////////
  34. // These classes are intentionally minimal right now. If you need additional
  35. // functionality, please contact someone with SSE experience (e.g., Falcon or
  36. // Huseby).
  37. /////////////////////////////
  38. // LLMatrix3a is the base class for LLRotation, which should be used instead any time you're dealing with a
  39. // rotation matrix.
  40. class LLMatrix3a
  41. {
  42. public:
  43. // Utility function for quickly transforming an array of LLVector4a's
  44. // For transforming a single LLVector4a, see LLVector4a::setRotated
  45. static void batchTransform( const LLMatrix3a& xform, const LLVector4a* src, int numVectors, LLVector4a* dst );
  46. // Utility function to obtain the identity matrix
  47. static inline const LLMatrix3a& getIdentity();
  48. //////////////////////////
  49. // Ctors
  50. //////////////////////////
  51. // Ctor
  52. LLMatrix3a() {}
  53. // Ctor for setting by columns
  54. inline LLMatrix3a( const LLVector4a& c0, const LLVector4a& c1, const LLVector4a& c2 );
  55. //////////////////////////
  56. // Get/Set
  57. //////////////////////////
  58. // Loads from an LLMatrix3
  59. inline void loadu(const LLMatrix3& src);
  60. // Set rows
  61. inline void setRows(const LLVector4a& r0, const LLVector4a& r1, const LLVector4a& r2);
  62. // Set columns
  63. inline void setColumns(const LLVector4a& c0, const LLVector4a& c1, const LLVector4a& c2);
  64. // Get the read-only access to a specified column. Valid columns are 0-2, but the
  65. // function is unchecked. You've been warned.
  66. inline const LLVector4a& getColumn(const U32 column) const;
  67. /////////////////////////
  68. // Matrix modification
  69. /////////////////////////
  70. // Set this matrix to the product of lhs and rhs ( this = lhs * rhs )
  71. void setMul( const LLMatrix3a& lhs, const LLMatrix3a& rhs );
  72. // Set this matrix to the transpose of src
  73. inline void setTranspose(const LLMatrix3a& src);
  74. // Set this matrix to a*w + b*(1-w)
  75. inline void setLerp(const LLMatrix3a& a, const LLMatrix3a& b, F32 w);
  76. /////////////////////////
  77. // Matrix inspection
  78. /////////////////////////
  79. // Sets all 4 elements in 'dest' to the determinant of this matrix.
  80. // If you will be using the determinant in subsequent ops with LLVector4a, use this version
  81. inline void getDeterminant( LLVector4a& dest ) const;
  82. // Returns the determinant as an LLSimdScalar. Use this if you will be using the determinant
  83. // primary for scalar operations.
  84. inline LLSimdScalar getDeterminant() const;
  85. // Returns nonzero if rows 0-2 and colums 0-2 contain no NaN or INF values. Row 3 is ignored
  86. inline LLBool32 isFinite() const;
  87. // Returns true if this matrix is equal to 'rhs' up to 'tolerance'
  88. inline bool isApproximatelyEqual( const LLMatrix3a& rhs, F32 tolerance = F_APPROXIMATELY_ZERO ) const;
  89. protected:
  90. LLVector4a mColumns[3];
  91. };
  92. class LLRotation : public LLMatrix3a
  93. {
  94. public:
  95. LLRotation() {}
  96. // Returns true if this rotation is orthonormal with det ~= 1
  97. inline bool isOkRotation() const;
  98. };
  99. #endif