-
Notifications
You must be signed in to change notification settings - Fork 12
/
rsQuat.h
62 lines (49 loc) · 1.91 KB
/
rsQuat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright (C) 1999-2010 Terence M. Welsh
*
* This file is part of rsMath.
*
* rsMath 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.
*
* rsMath 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 General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef RSQUAT_H
#define RSQUAT_H
class rsVec;
class rsQuat{
public:
float q[4];
rsQuat();
rsQuat(float x, float y, float z, float w);
~rsQuat();
void set(float x, float y, float z, float w); // x, y, z, w
void copy(rsQuat); // Copy another quaternion
void make(float a, float x, float y, float z); // angle, normalized axis
void make(float a, const rsVec &v); // angle, normalized axis
void normalize();
void preMult(rsQuat &postQuat); // Multiply this quaternion by
// the passed quaternion
// (this * passed)
void postMult(rsQuat &preQuat); // Multiply the passed quaternion
// by this quaternion
// (passed * this)
void toMat(float *); // Convert quaternion to array of 16 floats
void fromMat(float *); // Convert array of 16 floats to quaternion
void fromEuler(float, float, float); // Convert from hpr angles
void slerp(rsQuat, rsQuat, float); // Interpolate first quaternion
// to second using float from 0.0
// to 1.0
float & operator [] (int i) {return q[i];}
const float & operator [] (int i) const {return q[i];}
};
#endif