Changeset 336 in flair-src for trunk


Ignore:
Timestamp:
10/08/19 16:41:35 (5 years ago)
Author:
Sanahuja Guillaume
Message:

use float

Location:
trunk/lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/Euler.cpp

    r157 r336  
    8181*/
    8282void 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);
    8585
    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);
    8888
    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);
    9191
    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);
    9494}
    9595
  • trunk/lib/FlairCore/src/Quaternion.cpp

    r167 r336  
    3939
    4040float 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);
    4242}
    4343
     
    9494}
    9595
     96float Quaternion::GetEulerRoll(void) const {
     97    return atan2f(2 * (q0 * q1 + q2 * q3), 1 - 2 * (q1 * q1 + q2 * q2));
     98}
     99 
     100
     101float Quaternion::GetEulerPitch(void) const {
     102    return asinf(2 * (q0 * q2 - q1 * q3));
     103}
     104 
     105
     106float Quaternion::GetEulerYaw(void) const {
     107    return atan2f(2 * (q0 * q3 + q1 * q2), 1 - 2 * (q2 * q2 + q3 * q3));
     108}
     109 
    96110void 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();
    100114}
    101115
  • trunk/lib/FlairCore/src/Quaternion.h

    r167 r336  
    115115  */
    116116  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;
    117138
    118139  /*!
  • trunk/lib/FlairCore/src/Vector2D.cpp

    r167 r336  
    9292template <typename T> void Vector2D<T>::RotateDeg(float value) { Rotate(Euler::ToRadian(value)); }
    9393
    94 template <typename T> float Vector2D<T>::GetNorm(void) const { return sqrt(x * x + y * y); }
     94template <typename T> float Vector2D<T>::GetNorm(void) const { return sqrtf(x * x + y * y); }
    9595
    9696template <typename T> void Vector2D<T>::Normalize(void) {
  • trunk/lib/FlairCore/src/Vector3D.cpp

    r167 r336  
    218218}
    219219
    220 template <typename T> float Vector3D<T>::GetNorm(void) const { return sqrt(x * x + y * y + z * z); }
     220template <typename T> float Vector3D<T>::GetNorm(void) const { return sqrtf(x * x + y * y + z * z); }
    221221
    222222template <typename T> void Vector3D<T>::Normalize(void) {
  • trunk/lib/FlairFilter/src/JoyReference_impl.cpp

    r318 r336  
    174174  Vector3Df e_bar = theta_xy;
    175175  e_bar.Normalize();
    176   Quaternion q_xy(cos(theta_xy.GetNorm() / 2.0f),
    177                   e_bar.x * sin(theta_xy.GetNorm() / 2.0f),
    178                   e_bar.y * sin(theta_xy.GetNorm() / 2.0f), 0);
     176  Quaternion q_xy(cosf(theta_xy.GetNorm() / 2.0f),
     177                  e_bar.x * sinf(theta_xy.GetNorm() / 2.0f),
     178                  e_bar.y * sinf(theta_xy.GetNorm() / 2.0f), 0);
    179179  q_xy.Normalize();
    180180
  • trunk/lib/FlairFilter/src/TrajectoryGenerator2DCircle_impl.cpp

    r318 r336  
    7272
    7373  // configure trajectory
    74   angle_off = atan2(start_pos.y - pos_off.y, start_pos.x - pos_off.x);
     74  angle_off = atan2f(start_pos.y - pos_off.y, start_pos.x - pos_off.x);
    7575  CurrentTime = 0;
    7676}
     
    120120      if (CurrentTime < V / A) {
    121121        theta = angle_off + A / 2 * CurrentTime * CurrentTime / R;
    122         pos.x = R * cos(theta);
    123         pos.y = R * sin(theta);
    124         v.x = -A * CurrentTime * sin(theta);
    125         v.y = A * CurrentTime * cos(theta);
     122        pos.x = R * cosf(theta);
     123        pos.y = R * sinf(theta);
     124        v.x = -A * CurrentTime * sinf(theta);
     125        v.y = A * CurrentTime * cosf(theta);
    126126      } else {
    127127        if (!is_finishing) {
    128128          theta =
    129129              angle_off + V * V / (2 * A * R) + (CurrentTime - V / A) * V / R;
    130           pos.x = R * cos(theta);
    131           pos.y = R * sin(theta);
    132           v.x = -V * sin(theta);
    133           v.y = V * cos(theta);
     130          pos.x = R * cosf(theta);
     131          pos.y = R * sinf(theta);
     132          v.x = -V * sinf(theta);
     133          v.y = V * cosf(theta);
    134134        } else {
    135135          theta = angle_off + V * V / (2 * A * R) +
     
    138138                      (FinishTime - CurrentTime) / R +
    139139                  V * (CurrentTime - FinishTime) / R;
    140           pos.x = R * cos(theta);
    141           pos.y = R * sin(theta);
    142           v.x = -(V + A * (FinishTime - CurrentTime)) * sin(theta);
    143           v.y = (V + A * (FinishTime - CurrentTime)) * cos(theta);
     140          pos.x = R * cosf(theta);
     141          pos.y = R * sinf(theta);
     142          v.x = -(V + A * (FinishTime - CurrentTime)) * sinf(theta);
     143          v.y = (V + A * (FinishTime - CurrentTime)) * cosf(theta);
    144144        }
    145145      }
  • trunk/lib/FlairSensorActuator/src/HostEthController.cpp

    r290 r336  
    9090  for (unsigned int i = 0; i < axisNumber; i++) {
    9191    // Start a new row or add up to the current row? We try to keep a 4/3 ratio
    92     unsigned int columns = sqrt(4.0 * axisNumber / 3.0);
     92    unsigned int columns = sqrtf(4.0 * axisNumber / 3.0);
    9393    LayoutPosition *position;
    9494    if (i % columns == 0) {
Note: See TracChangeset for help on using the changeset viewer.