Changeset 336 in flair-src for trunk/lib/FlairCore
- Timestamp:
- Oct 8, 2019, 4:41:35 PM (5 years ago)
- Location:
- trunk/lib/FlairCore/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Euler.cpp
r157 r336 81 81 */ 82 82 void Euler::ToQuaternion(Quaternion &quaternion) const { 83 quaternion.q0 = cos (yaw / 2) * cos(pitch / 2) * cos(roll / 2) +84 sin (yaw / 2) * sin(pitch / 2) * sin(roll / 2);83 quaternion.q0 = cosf(yaw / 2.0f) * cosf(pitch / 2.0f) * cosf(roll / 2.0f) + 84 sinf(yaw / 2.0f) * sinf(pitch / 2.0f) * sinf(roll / 2.0f); 85 85 86 quaternion.q1 = cos (yaw / 2) * cos(pitch / 2) * sin(roll / 2) -87 sin (yaw / 2) * sin(pitch / 2) * cos(roll / 2);86 quaternion.q1 = cosf(yaw / 2.0f) * cosf(pitch / 2.0f) * sinf(roll / 2.0f) - 87 sinf(yaw / 2.0f) * sinf(pitch / 2.0f) * cosf(roll / 2.0f); 88 88 89 quaternion.q2 = cos (yaw / 2) * sin(pitch / 2) * cos(roll / 2) +90 sin (yaw / 2) * cos(pitch / 2) * sin(roll / 2);89 quaternion.q2 = cosf(yaw / 2.0f) * sinf(pitch / 2.0f) * cosf(roll / 2.0f) + 90 sinf(yaw / 2.0f) * cosf(pitch / 2.0f) * sinf(roll / 2.0f); 91 91 92 quaternion.q3 = sin (yaw / 2) * cos(pitch / 2) * cos(roll / 2) -93 cos (yaw / 2) * sin(pitch / 2) * sin(roll / 2);92 quaternion.q3 = sinf(yaw / 2.0f) * cosf(pitch / 2.0f) * cosf(roll / 2.0f) - 93 cosf(yaw / 2.0f) * sinf(pitch / 2.0f) * sinf(roll / 2.0f); 94 94 } 95 95 -
trunk/lib/FlairCore/src/Quaternion.cpp
r167 r336 39 39 40 40 float Quaternion::GetNorm(void) const { 41 return sqrt (q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3);41 return sqrtf(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); 42 42 } 43 43 … … 94 94 } 95 95 96 float Quaternion::GetEulerRoll(void) const { 97 return atan2f(2 * (q0 * q1 + q2 * q3), 1 - 2 * (q1 * q1 + q2 * q2)); 98 } 99 100 101 float Quaternion::GetEulerPitch(void) const { 102 return asinf(2 * (q0 * q2 - q1 * q3)); 103 } 104 105 106 float Quaternion::GetEulerYaw(void) const { 107 return atan2f(2 * (q0 * q3 + q1 * q2), 1 - 2 * (q2 * q2 + q3 * q3)); 108 } 109 96 110 void Quaternion::ToEuler(Euler &euler) const { 97 euler.roll = atan2(2 * (q0 * q1 + q2 * q3), 1 - 2 * (q1 * q1 + q2 * q2));98 euler.pitch = asin(2 * (q0 * q2 - q1 * q3));99 euler.yaw = atan2(2 * (q0 * q3 + q1 * q2), 1 - 2 * (q2 * q2 + q3 * q3));111 euler.roll = GetEulerRoll(); 112 euler.pitch = GetEulerPitch(); 113 euler.yaw = GetEulerYaw(); 100 114 } 101 115 -
trunk/lib/FlairCore/src/Quaternion.h
r167 r336 115 115 */ 116 116 Euler ToEuler(void) const; 117 118 /*! 119 * \brief Get roll euler angle 120 * 121 * \return roll euler angle 122 */ 123 float GetEulerRoll(void) const; 124 125 /*! 126 * \brief Get pitch euler angle 127 * 128 * \return pitch euler angle 129 */ 130 float GetEulerPitch(void) const; 131 132 /*! 133 * \brief Get yaw euler angle 134 * 135 * \return yaw euler angle 136 */ 137 float GetEulerYaw(void) const; 117 138 118 139 /*! -
trunk/lib/FlairCore/src/Vector2D.cpp
r167 r336 92 92 template <typename T> void Vector2D<T>::RotateDeg(float value) { Rotate(Euler::ToRadian(value)); } 93 93 94 template <typename T> float Vector2D<T>::GetNorm(void) const { return sqrt (x * x + y * y); }94 template <typename T> float Vector2D<T>::GetNorm(void) const { return sqrtf(x * x + y * y); } 95 95 96 96 template <typename T> void Vector2D<T>::Normalize(void) { -
trunk/lib/FlairCore/src/Vector3D.cpp
r167 r336 218 218 } 219 219 220 template <typename T> float Vector3D<T>::GetNorm(void) const { return sqrt (x * x + y * y + z * z); }220 template <typename T> float Vector3D<T>::GetNorm(void) const { return sqrtf(x * x + y * y + z * z); } 221 221 222 222 template <typename T> void Vector3D<T>::Normalize(void) {
Note:
See TracChangeset
for help on using the changeset viewer.