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