Newer
Older
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/********************************************************************************
* *
* S i n g l e - P r e c i s i o n Q u a t e r n i o n *
* *
*********************************************************************************
* Copyright (C) 1994,2006 by Jeroen van der Zijp. All Rights Reserved. *
*********************************************************************************
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*********************************************************************************
* $Id: FXQuatf.h 2344 2006-02-12 21:19:36Z lyle $ *
********************************************************************************/
#ifndef FXQUATF_H
#define FXQUATF_H
namespace FX {
class FXMat3f;
/// Single-precision quaternion
class FXAPI FXQuatf : public FXVec4f {
public:
/// Construct
FXQuatf(){}
/// Copy constructor
FXQuatf(const FXQuatf& q):FXVec4f(q){}
/// Construct from components
FXQuatf(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww):FXVec4f(xx,yy,zz,ww){}
/// Construct from array of floats
FXQuatf(const FXfloat v[]):FXVec4f(v){}
/// Construct from axis and angle
FXQuatf(const FXVec3f& axis,FXfloat phi=0.0f);
/// Construct from euler angles yaw (z), pitch (y), and roll (x)
FXQuatf(FXfloat roll,FXfloat pitch,FXfloat yaw);
/// Construct quaternion from two unit vectors
FXQuatf(const FXVec3f& fr,const FXVec3f& to);
/// Construct quaternion from three axes
FXQuatf(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez);
/// Construct quaternion from 3x3 matrix
FXQuatf(const FXMat3f& mat);
/// Adjust quaternion length
FXQuatf& adjust();
/// Set quaternion from axis and angle
void setAxisAngle(const FXVec3f& axis,FXfloat phi=0.0f);
/// Obtain axis and angle from quaternion
void getAxisAngle(FXVec3f& axis,FXfloat& phi) const;
/// Set quaternion from roll (x), pitch (y), yaw (z)
void setRollPitchYaw(FXfloat roll,FXfloat pitch,FXfloat yaw);
void getRollPitchYaw(FXfloat& roll,FXfloat& pitch,FXfloat& yaw) const;
/// Set quaternion from yaw (z), pitch (y), roll (x)
void setYawPitchRoll(FXfloat yaw,FXfloat pitch,FXfloat roll);
void getYawPitchRoll(FXfloat& yaw,FXfloat& pitch,FXfloat& roll) const;
/// Set quaternion from roll (x), yaw (z), pitch (y)
void setRollYawPitch(FXfloat roll,FXfloat yaw,FXfloat pitch);
void getRollYawPitch(FXfloat& roll,FXfloat& yaw,FXfloat& pitch) const;
/// Set quaternion from pitch (y), roll (x),yaw (z)
void setPitchRollYaw(FXfloat pitch,FXfloat roll,FXfloat yaw);
void getPitchRollYaw(FXfloat& pitch,FXfloat& roll,FXfloat& yaw) const;
/// Set quaternion from pitch (y), yaw (z), roll (x)
void setPitchYawRoll(FXfloat pitch,FXfloat yaw,FXfloat roll);
void getPitchYawRoll(FXfloat& pitch,FXfloat& yaw,FXfloat& roll) const;
/// Set quaternion from yaw (z), roll (x), pitch (y)
void setYawRollPitch(FXfloat yaw,FXfloat roll,FXfloat pitch);
void getYawRollPitch(FXfloat& yaw,FXfloat& roll,FXfloat& pitch) const;
/// Set quaternion from axes
void setAxes(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez);
/// Get quaternion axes
void getAxes(FXVec3f& ex,FXVec3f& ey,FXVec3f& ez) const;
/// Obtain local x axis
FXVec3f getXAxis() const;
/// Obtain local y axis
FXVec3f getYAxis() const;
/// Obtain local z axis
FXVec3f getZAxis() const;
/// Exponentiate quaternion
FXQuatf exp() const;
/// Take logarithm of quaternion
FXQuatf log() const;
/// Invert quaternion
FXQuatf invert() const;
/// Invert unit quaternion
FXQuatf unitinvert() const;
/// Conjugate quaternion
FXQuatf conj() const;
/// Construct quaternion from arc a->b on unit sphere
FXQuatf& arc(const FXVec3f& a,const FXVec3f& b);
/// Spherical lerp
FXQuatf& lerp(const FXQuatf& u,const FXQuatf& v,FXfloat f);
/// Multiply quaternions
FXQuatf operator*(const FXQuatf& q) const;
/// Rotation of a vector by a quaternion
FXVec3f operator*(const FXVec3f& v) const;
};
}
#endif