Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXQuatf.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * 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 *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1994,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXQuatf.h,v 1.17 2006/01/22 17:58:07 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXQUATF_H
25 #define FXQUATF_H
26 
27 
28 namespace FX {
29 
30 
31 class FXMat3f;
32 
33 
34 /// Single-precision quaternion
35 class FXAPI FXQuatf : public FXVec4f {
36 public:
37 
38  /// Construct
39  FXQuatf(){}
40 
41  /// Copy constructor
42  FXQuatf(const FXQuatf& q):FXVec4f(q){}
43 
44  /// Construct from components
45  FXQuatf(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww):FXVec4f(xx,yy,zz,ww){}
46 
47  /// Construct from array of floats
48  FXQuatf(const FXfloat v[]):FXVec4f(v){}
49 
50  /// Construct from axis and angle
51  FXQuatf(const FXVec3f& axis,FXfloat phi=0.0f);
52 
53  /// Construct from euler angles yaw (z), pitch (y), and roll (x)
54  FXQuatf(FXfloat roll,FXfloat pitch,FXfloat yaw);
55 
56  /// Construct quaternion from two unit vectors
57  FXQuatf(const FXVec3f& fr,const FXVec3f& to);
58 
59  /// Construct quaternion from three axes
60  FXQuatf(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez);
61 
62  /// Construct quaternion from 3x3 matrix
63  FXQuatf(const FXMat3f& mat);
64 
65  /// Adjust quaternion length
66  FXQuatf& adjust();
67 
68  /// Set quaternion from axis and angle
69  void setAxisAngle(const FXVec3f& axis,FXfloat phi=0.0f);
70 
71  /// Obtain axis and angle from quaternion
72  void getAxisAngle(FXVec3f& axis,FXfloat& phi) const;
73 
74  /// Set quaternion from roll (x), pitch (y), yaw (z)
75  void setRollPitchYaw(FXfloat roll,FXfloat pitch,FXfloat yaw);
76  void getRollPitchYaw(FXfloat& roll,FXfloat& pitch,FXfloat& yaw) const;
77 
78  /// Set quaternion from yaw (z), pitch (y), roll (x)
79  void setYawPitchRoll(FXfloat yaw,FXfloat pitch,FXfloat roll);
80  void getYawPitchRoll(FXfloat& yaw,FXfloat& pitch,FXfloat& roll) const;
81 
82  /// Set quaternion from roll (x), yaw (z), pitch (y)
83  void setRollYawPitch(FXfloat roll,FXfloat yaw,FXfloat pitch);
84  void getRollYawPitch(FXfloat& roll,FXfloat& yaw,FXfloat& pitch) const;
85 
86  /// Set quaternion from pitch (y), roll (x),yaw (z)
87  void setPitchRollYaw(FXfloat pitch,FXfloat roll,FXfloat yaw);
88  void getPitchRollYaw(FXfloat& pitch,FXfloat& roll,FXfloat& yaw) const;
89 
90  /// Set quaternion from pitch (y), yaw (z), roll (x)
91  void setPitchYawRoll(FXfloat pitch,FXfloat yaw,FXfloat roll);
92  void getPitchYawRoll(FXfloat& pitch,FXfloat& yaw,FXfloat& roll) const;
93 
94  /// Set quaternion from yaw (z), roll (x), pitch (y)
95  void setYawRollPitch(FXfloat yaw,FXfloat roll,FXfloat pitch);
96  void getYawRollPitch(FXfloat& yaw,FXfloat& roll,FXfloat& pitch) const;
97 
98  /// Set quaternion from axes
99  void setAxes(const FXVec3f& ex,const FXVec3f& ey,const FXVec3f& ez);
100 
101  /// Get quaternion axes
102  void getAxes(FXVec3f& ex,FXVec3f& ey,FXVec3f& ez) const;
103 
104  /// Obtain local x axis
105  FXVec3f getXAxis() const;
106 
107  /// Obtain local y axis
108  FXVec3f getYAxis() const;
109 
110  /// Obtain local z axis
111  FXVec3f getZAxis() const;
112 
113  /// Exponentiate quaternion
114  FXQuatf exp() const;
115 
116  /// Take logarithm of quaternion
117  FXQuatf log() const;
118 
119  /// Invert quaternion
120  FXQuatf invert() const;
121 
122  /// Invert unit quaternion
123  FXQuatf unitinvert() const;
124 
125  /// Conjugate quaternion
126  FXQuatf conj() const;
127 
128  /// Construct quaternion from arc a->b on unit sphere
129  FXQuatf& arc(const FXVec3f& a,const FXVec3f& b);
130 
131  /// Spherical lerp
132  FXQuatf& lerp(const FXQuatf& u,const FXQuatf& v,FXfloat f);
133 
134  /// Multiply quaternions
135  FXQuatf operator*(const FXQuatf& q) const;
136 
137  /// Rotation of a vector by a quaternion
138  FXVec3f operator*(const FXVec3f& v) const;
139  };
140 
141 
142 }
143 
144 #endif
FXQuatf(const FXfloat v[])
Construct from array of floats.
Definition: FXQuatf.h:48
FXQuatf()
Construct.
Definition: FXQuatf.h:39
FXQuatf(FXfloat xx, FXfloat yy, FXfloat zz, FXfloat ww)
Construct from components.
Definition: FXQuatf.h:45
#define FXAPI
Definition: fxdefs.h:122
Single-precision 3x3 matrix.
Definition: FXMat3f.h:35
Definition: FX4Splitter.h:31
Single-precision quaternion.
Definition: FXQuatf.h:35
Single-precision 3-element vector.
Definition: FXVec3f.h:36
float FXfloat
Definition: fxdefs.h:391
FXQuatf(const FXQuatf &q)
Copy constructor.
Definition: FXQuatf.h:42
FXMat3d operator*(FXdouble x, const FXMat3d &a)
Single-precision 4-element vector.
Definition: FXVec4f.h:35

Copyright © 1997-2005 Jeroen van der Zijp