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

FXQuatd.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * D o u b 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: FXQuatd.h,v 1.15 2006/01/22 17:58:07 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXQUATD_H
25 #define FXQUATD_H
26 
27 
28 namespace FX {
29 
30 
31 class FXMat3d;
32 
33 
34 /// Double-precision quaternion
35 class FXAPI FXQuatd : public FXVec4d {
36 public:
37 
38  /// Constructors
39  FXQuatd(){}
40 
41  /// Copy constructor
42  FXQuatd(const FXQuatd& q):FXVec4d(q){}
43 
44  /// Construct from components
45  FXQuatd(FXdouble xx,FXdouble yy,FXdouble zz,FXdouble ww):FXVec4d(xx,yy,zz,ww){}
46 
47  /// Construct from array of doubles
48  FXQuatd(const FXdouble v[]):FXVec4d(v){}
49 
50  /// Construct from axis and angle
51  FXQuatd(const FXVec3d& axis,FXdouble phi=0.0);
52 
53  /// Construct from euler angles yaw (z), pitch (y), and roll (x)
54  FXQuatd(FXdouble roll,FXdouble pitch,FXdouble yaw);
55 
56  /// Construct quaternion from two unit vectors
57  FXQuatd(const FXVec3d& fr,const FXVec3d& to);
58 
59  /// Construct quaternion from three axes
60  FXQuatd(const FXVec3d& ex,const FXVec3d& ey,const FXVec3d& ez);
61 
62  /// Construct quaternion from 3x3 matrix
63  FXQuatd(const FXMat3d& mat);
64 
65  /// Adjust quaternion length
66  FXQuatd& adjust();
67 
68  /// Set quaternion from axis and angle
69  void setAxisAngle(const FXVec3d& axis,FXdouble phi=0.0);
70 
71  /// Obtain axis and angle from quaternion
72  void getAxisAngle(FXVec3d& axis,FXdouble& phi) const;
73 
74  /// Set quaternion from roll (x), pitch (y), yaw (z)
75  void setRollPitchYaw(FXdouble roll,FXdouble pitch,FXdouble yaw);
76  void getRollPitchYaw(FXdouble& roll,FXdouble& pitch,FXdouble& yaw) const;
77 
78  /// Set quaternion from yaw (z), pitch (y), roll (x)
79  void setYawPitchRoll(FXdouble yaw,FXdouble pitch,FXdouble roll);
80  void getYawPitchRoll(FXdouble& yaw,FXdouble& pitch,FXdouble& roll) const;
81 
82  /// Set quaternion from roll (x), yaw (z), pitch (y)
83  void setRollYawPitch(FXdouble roll,FXdouble yaw,FXdouble pitch);
84  void getRollYawPitch(FXdouble& roll,FXdouble& yaw,FXdouble& pitch) const;
85 
86  /// Set quaternion from pitch (y), roll (x),yaw (z)
87  void setPitchRollYaw(FXdouble pitch,FXdouble roll,FXdouble yaw);
88  void getPitchRollYaw(FXdouble& pitch,FXdouble& roll,FXdouble& yaw) const;
89 
90  /// Set quaternion from pitch (y), yaw (z), roll (x)
91  void setPitchYawRoll(FXdouble pitch,FXdouble yaw,FXdouble roll);
92  void getPitchYawRoll(FXdouble& pitch,FXdouble& yaw,FXdouble& roll) const;
93 
94  /// Set quaternion from yaw (z), roll (x), pitch (y)
95  void setYawRollPitch(FXdouble yaw,FXdouble roll,FXdouble pitch);
96  void getYawRollPitch(FXdouble& yaw,FXdouble& roll,FXdouble& pitch) const;
97 
98  /// Set quaternion from axes
99  void setAxes(const FXVec3d& ex,const FXVec3d& ey,const FXVec3d& ez);
100 
101  /// Get quaternion axes
102  void getAxes(FXVec3d& ex,FXVec3d& ey,FXVec3d& ez) const;
103 
104  /// Obtain local x axis
105  FXVec3d getXAxis() const;
106 
107  /// Obtain local y axis
108  FXVec3d getYAxis() const;
109 
110  /// Obtain local z axis
111  FXVec3d getZAxis() const;
112 
113  /// Exponentiate quaternion
114  FXQuatd exp() const;
115 
116  /// Take logarithm of quaternion
117  FXQuatd log() const;
118 
119  /// Invert quaternion
120  FXQuatd invert() const;
121 
122  /// Invert unit quaternion
123  FXQuatd unitinvert() const;
124 
125  /// Conjugate quaternion
126  FXQuatd conj() const;
127 
128  /// Construct quaternion from arc a->b on unit sphere
129  FXQuatd& arc(const FXVec3d& a,const FXVec3d& b);
130 
131  /// Spherical lerp
132  FXQuatd& lerp(const FXQuatd& u,const FXQuatd& v,FXdouble f);
133 
134  /// Multiply quaternions
135  FXQuatd operator*(const FXQuatd& q) const;
136 
137  /// Rotation of a vector by a quaternion
138  FXVec3d operator*(const FXVec3d& v) const;
139  };
140 
141 
142 }
143 
144 #endif
Double-precision quaternion.
Definition: FXQuatd.h:35
Double-precision 3-element vector.
Definition: FXVec3d.h:36
#define FXAPI
Definition: fxdefs.h:122
double FXdouble
Definition: fxdefs.h:392
Definition: FX4Splitter.h:31
Double-precision 4-element vector.
Definition: FXVec4d.h:35
FXQuatd(FXdouble xx, FXdouble yy, FXdouble zz, FXdouble ww)
Construct from components.
Definition: FXQuatd.h:45
Double-precision 3x3 matrix.
Definition: FXMat3d.h:35
FXQuatd()
Constructors.
Definition: FXQuatd.h:39
FXQuatd(const FXdouble v[])
Construct from array of doubles.
Definition: FXQuatd.h:48
FXMat3d operator*(FXdouble x, const FXMat3d &a)
FXQuatd(const FXQuatd &q)
Copy constructor.
Definition: FXQuatd.h:42

Copyright © 1997-2005 Jeroen van der Zijp