22 #ifndef _QUATERNION_HH_
23 #define _QUATERNION_HH_
55 public:
Quaternion(
const double &_w,
const double &_x,
const double &_y,
62 public:
Quaternion(
const double &_roll,
const double &_pitch,
86 public:
void Invert();
93 Quaternion q(this->w, this->x, this->y, this->z);
96 s = q.
w * q.
w + q.
x * q.
x + q.
y * q.
y + q.
z * q.
z;
118 public:
void SetToIdentity();
129 public:
void Normalize();
136 public:
void SetFromAxis(
double _x,
double _y,
double _z,
double _a);
141 public:
void SetFromAxis(
const Vector3 &_axis,
double _a);
148 public:
void Set(
double _u,
double _x,
double _y,
double _z);
153 public:
void SetFromEuler(
const Vector3 &_vec);
159 public:
void SetFromEuler(
double _roll,
double _pitch,
double _yaw);
163 public:
Vector3 GetAsEuler()
const;
173 public:
static Quaternion EulerToQuaternion(
double _x,
179 public:
double GetRoll();
183 public:
double GetPitch();
187 public:
double GetYaw();
192 public:
void GetAsAxis(
Vector3 &_axis,
double &_angle)
const;
196 public:
void Scale(
double _scale);
224 this->w*_q.
w - this->x*_q.
x - this->y*_q.
y - this->z*_q.
z,
225 this->w*_q.
x + this->x*_q.
w + this->y*_q.
z - this->z*_q.
y,
226 this->w*_q.
y - this->x*_q.
z + this->y*_q.
w + this->z*_q.
x,
227 this->w*_q.
z + this->x*_q.
y - this->y*_q.
x + this->z*_q.
w);
233 public:
Quaternion operator*(
const double &_f)
const;
247 public:
bool operator ==(
const Quaternion &_qt)
const;
252 public:
bool operator!=(
const Quaternion &_qt)
const;
264 tmp = (*this) * (tmp * this->GetInverse());
275 public:
bool IsFinite()
const;
280 if (!std::isfinite(this->x))
282 if (!std::isfinite(this->y))
284 if (!std::isfinite(this->z))
286 if (!std::isfinite(this->w))
299 public:
Matrix3 GetAsMatrix3()
const;
303 public:
Matrix4 GetAsMatrix4()
const;
307 public:
Vector3 GetXAxis()
const;
311 public:
Vector3 GetYAxis()
const;
315 public:
Vector3 GetZAxis()
const;
319 public:
void Round(
int _precision);
324 public:
double Dot(
const Quaternion &_q)
const;
337 const Quaternion &_rkQ,
bool _shortestPath =
false);
347 const Quaternion &_rkQ,
bool _shortestPath =
false);
382 Angle roll, pitch, yaw;
385 _in.setf(std::ios_base::skipws);
386 _in >> roll >> pitch >> yaw;