69 float pitch()
const {
return mPitch; }
74 float roll()
const {
return mRoll; }
79 float yaw()
const {
return mYaw; }
86 std::ostringstream stm;
87 stm <<
"pitch: " << mPitch <<
", roll: " << mRoll <<
", yaw: " << mYaw;
121 float w()
const {
return mW; }
126 float x()
const {
return mX; }
131 float y()
const {
return mY; }
136 float z()
const {
return mZ; }
143 std::ostringstream stm;
144 stm <<
"w: " << mW <<
", x: " << mX <<
", y: " << mY <<
", z: " << mZ;
154 static const float PI = 3.14159265f;
155 float pitch = 0, roll = 0, yaw = 0;
156 double test = mY*mZ + mX*mW;
157 if (std::abs(test) > 0.4999f){
158 int symbol = (test > 0.4999f) ? 1 : -1;
159 yaw = symbol * 2 * std::atan2f(mY, mW) * 180 / PI;
160 pitch = symbol * 90.f;
162 return Euler(pitch, roll, yaw);
164 yaw = std::atan2f((2 * mZ*mW - 2 * mX*mY), (1 - 2 * mX*mX - 2 * mZ*mZ)) * 180 / PI;
165 pitch = (float)std::asin(2 * test) * 180 / PI;
166 roll = std::atan2f((2 * mY*mW - 2 * mX*mZ), (1 - 2 * mX*mX - 2 * mY*mY)) * 180 / PI;
167 return Euler(pitch, roll, yaw);
Quaternion()
Default constructor.
Definition: Quaternion.h:106
std::string toString() const
Get a human-readable value.
Definition: Quaternion.h:141
Data type of quaternion.
Definition: Quaternion.h:101
Euler()
Default constructor.
Definition: Quaternion.h:55
Euler(float pitch, float roll, float yaw)
Constructor with 3 elements.
Definition: Quaternion.h:59
Euler toEuler() const
Convert quaternion to Eulerian angle.
Definition: Quaternion.h:152
float roll() const
Get roll.
Definition: Quaternion.h:74
float x() const
Get X.
Definition: Quaternion.h:126
float pitch() const
Get pitch.
Definition: Quaternion.h:69
The namespace in which all of the gForceSDK project definitions are contained.
Definition: Device.h:42
float w() const
Get W.
Definition: Quaternion.h:121
Data type of Eulerian angle.
Definition: Quaternion.h:50
std::string toString() const
Get a human-readable value.
Definition: Quaternion.h:84
float yaw() const
Get yaw.
Definition: Quaternion.h:79
Quaternion(float w, float x, float y, float z)
Constructor with 4 elements.
Definition: Quaternion.h:110
float y() const
Get Y.
Definition: Quaternion.h:131
float z() const
Get Z.
Definition: Quaternion.h:136