2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code 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
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../precompiled.h"
38 idAngles idRotation::ToAngles( void ) const {
39 return ToMat3().ToAngles();
47 idQuat idRotation::ToQuat( void ) const {
50 a = angle * ( idMath::M_DEG2RAD * 0.5f );
51 idMath::SinCos( a, s, c );
52 return idQuat( vec.x * s, vec.y * s, vec.z * s, c );
60 const idMat3 &idRotation::ToMat3( void ) const {
65 float a, c, s, x, y, z;
71 a = angle * ( idMath::M_DEG2RAD * 0.5f );
72 idMath::SinCos( a, s, c );
94 axis[ 0 ][ 0 ] = 1.0f - ( yy + zz );
95 axis[ 0 ][ 1 ] = xy - wz;
96 axis[ 0 ][ 2 ] = xz + wy;
98 axis[ 1 ][ 0 ] = xy + wz;
99 axis[ 1 ][ 1 ] = 1.0f - ( xx + zz );
100 axis[ 1 ][ 2 ] = yz - wx;
102 axis[ 2 ][ 0 ] = xz - wy;
103 axis[ 2 ][ 1 ] = yz + wx;
104 axis[ 2 ][ 2 ] = 1.0f - ( xx + yy );
116 idMat4 idRotation::ToMat4( void ) const {
117 return ToMat3().ToMat4();
122 idRotation::ToAngularVelocity
125 idVec3 idRotation::ToAngularVelocity( void ) const {
126 return vec * DEG2RAD( angle );
131 idRotation::Normalize180
134 void idRotation::Normalize180( void ) {
135 angle -= floor( angle / 360.0f ) * 360.0f;
136 if ( angle > 180.0f ) {
139 else if ( angle < -180.0f ) {
146 idRotation::Normalize360
149 void idRotation::Normalize360( void ) {
150 angle -= floor( angle / 360.0f ) * 360.0f;
151 if ( angle > 360.0f ) {
154 else if ( angle < 0.0f ) {