scummvm/common/matrix3.h

87 lines
2.2 KiB
C
Raw Normal View History

2006-04-02 14:20:45 +00:00
/* Residual - Virtual machine to run LucasArts' 3D adventure games
* Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
* $URL$
* $Id$
*
*/
#ifndef COMMON_MATRIX3_H
#define COMMON_MATRIX3_H
#include "common/vector3d.h"
// matrix 3 is a rotation matrix
class Matrix3{
public:
2004-12-09 23:55:43 +00:00
Vector3d _right;
Vector3d _up;
Vector3d _at;
2004-12-09 23:55:43 +00:00
void buildFromPitchYawRoll(float pitch, float yaw, float roll);
void setAsIdentity();
2004-12-09 23:55:43 +00:00
void constructAroundPitch(float pitch);
void constructAroundYaw(float pitch);
void constructAroundRoll(float pitch);
2004-12-09 23:55:43 +00:00
void getPitchYawRoll(float* pPitch, float* pYaw, float* pRoll);
float getPitch();
float getYaw();
float getRoll();
2004-12-09 23:55:43 +00:00
void transform(Vector3d* v);
// operators
Matrix3& operator *=(const Matrix3& s) {
float x, y, z;
2004-12-09 23:55:43 +00:00
x = _right.dotProduct(s._right.x(), s._up.x(), s._at.x());
y = _right.dotProduct(s._right.y(), s._up.y(), s._at.y());
z = _right.dotProduct(s._right.z(), s._up.z(), s._at.z());
2004-12-09 23:55:43 +00:00
_right.set(x, y, z);
2004-12-09 23:55:43 +00:00
x = _up.dotProduct(s._right.x(), s._up.x(), s._at.x());
y = _up.dotProduct(s._right.y(), s._up.y(), s._at.y());
z = _up.dotProduct(s._right.z(), s._up.z(), s._at.z());
2004-12-09 23:55:43 +00:00
_up.set( x, y, z );
2004-12-09 23:55:43 +00:00
x = _at.dotProduct(s._right.x(), s._up.x(), s._at.x());
y = _at.dotProduct(s._right.y(), s._up.y(), s._at.y());
z = _at.dotProduct(s._right.z(), s._up.z(), s._at.z());
2004-12-09 23:55:43 +00:00
_at.set(x, y, z);
return *this;
}
Matrix3& operator =(const Matrix3& s) {
2004-12-09 23:55:43 +00:00
_right = s._right;
_up = s._up;
_at = s._at;
return *this;
}
private:
};
2003-08-28 02:01:48 +00:00
#endif // MATRIX_HH