PageRenderTime 26ms CodeModel.GetById 13ms app.highlight 8ms 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
  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
 27#ifndef	LL_QUATERNION2_H
 28#define	LL_QUATERNION2_H
 29
 30/////////////////////////////
 31// LLQuaternion2
 32/////////////////////////////
 33// This class stores a quaternion x*i + y*j + z*k + w in <x, y, z, w> order
 34// (i.e., w in high order element of vector)
 35/////////////////////////////
 36/////////////////////////////
 37// These classes are intentionally minimal right now. If you need additional
 38// functionality, please contact someone with SSE experience (e.g., Falcon or
 39// Huseby).
 40/////////////////////////////
 41#include "llquaternion.h"
 42
 43class LLQuaternion2
 44{
 45public:
 46
 47	//////////////////////////
 48	// Ctors
 49	//////////////////////////
 50	
 51	// Ctor
 52	LLQuaternion2() {}
 53
 54	// Ctor from LLQuaternion
 55	explicit LLQuaternion2( const class LLQuaternion& quat );
 56
 57	//////////////////////////
 58	// Get/Set
 59	//////////////////////////
 60
 61	// Load from an LLQuaternion
 62	inline void operator=( const LLQuaternion& quat )
 63	{
 64		mQ.loadua( quat.mQ );
 65	}
 66
 67	// Return the internal LLVector4a representation of the quaternion
 68	inline const LLVector4a& getVector4a() const;
 69	inline LLVector4a& getVector4aRw();
 70
 71	/////////////////////////
 72	// Quaternion modification
 73	/////////////////////////
 74	
 75	// Set this quaternion to the conjugate of src
 76	inline void setConjugate(const LLQuaternion2& src);
 77
 78	// Renormalizes the quaternion. Assumes it has nonzero length.
 79	inline void normalize();
 80
 81	// Quantize this quaternion to 8 bit precision
 82	inline void quantize8();
 83
 84	// Quantize this quaternion to 16 bit precision
 85	inline void quantize16();
 86
 87	/////////////////////////
 88	// Quaternion inspection
 89	/////////////////////////
 90
 91	// Return true if this quaternion is equal to 'rhs'. 
 92	// Note! Quaternions exhibit "double-cover", so any rotation has two equally valid
 93	// quaternion representations and they will NOT compare equal.
 94	inline bool equals(const LLQuaternion2& rhs, F32 tolerance = F_APPROXIMATELY_ZERO ) const;
 95
 96	// Return true if all components are finite and the quaternion is normalized
 97	inline bool isOkRotation() const;
 98
 99protected:
100
101	LLVector4a mQ;
102
103};
104
105#endif