Changeset 15 in flair-src for trunk/lib/FlairCore/src/Euler.cpp


Ignore:
Timestamp:
Apr 8, 2016, 3:40:57 PM (5 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

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

    r2 r15  
    2323#define PI_D ((double)3.14159265358979323846)
    2424
    25 namespace flair
    26 {
    27 namespace core
    28 {
     25namespace flair {
     26namespace core {
    2927
    30 Euler::Euler(float inRoll,float inPitch,float inYaw): roll(inRoll), pitch(inPitch),yaw(inYaw) {
    31 }
     28Euler::Euler(float inRoll, float inPitch, float inYaw)
     29    : roll(inRoll), pitch(inPitch), yaw(inYaw) {}
    3230
    33 Euler::~Euler() {
     31Euler::~Euler() {}
    3432
    35 }
    36 
    37 Euler& Euler::operator=(const Euler &euler) {
    38     roll=euler.roll;
    39     pitch=euler.pitch;
    40     yaw=euler.yaw;
    41     return (*this);
     33Euler &Euler::operator=(const Euler &euler) {
     34  roll = euler.roll;
     35  pitch = euler.pitch;
     36  yaw = euler.yaw;
     37  return (*this);
    4238}
    4339/*
     
    8581*/
    8682void Euler::ToQuaternion(Quaternion &quaternion) const {
    87     quaternion.q0=cos(yaw/2)*cos(pitch/2)*cos(roll/2)
    88         +sin(yaw/2)*sin(pitch/2)*sin(roll/2);
     83  quaternion.q0 = cos(yaw / 2) * cos(pitch / 2) * cos(roll / 2) +
     84                  sin(yaw / 2) * sin(pitch / 2) * sin(roll / 2);
    8985
    90     quaternion.q1=cos(yaw/2)*cos(pitch/2)*sin(roll/2)
    91         -sin(yaw/2)*sin(pitch/2)*cos(roll/2);
     86  quaternion.q1 = cos(yaw / 2) * cos(pitch / 2) * sin(roll / 2) -
     87                  sin(yaw / 2) * sin(pitch / 2) * cos(roll / 2);
    9288
    93     quaternion.q2=cos(yaw/2)*sin(pitch/2)*cos(roll/2)
    94         +sin(yaw/2)*cos(pitch/2)*sin(roll/2);
     89  quaternion.q2 = cos(yaw / 2) * sin(pitch / 2) * cos(roll / 2) +
     90                  sin(yaw / 2) * cos(pitch / 2) * sin(roll / 2);
    9591
    96     quaternion.q3=sin(yaw/2)*cos(pitch/2)*cos(roll/2)
    97         -cos(yaw/2)*sin(pitch/2)*sin(roll/2);
     92  quaternion.q3 = sin(yaw / 2) * cos(pitch / 2) * cos(roll / 2) -
     93                  cos(yaw / 2) * sin(pitch / 2) * sin(roll / 2);
    9894}
    9995
    10096Quaternion Euler::ToQuaternion(void) const {
    101     Quaternion quaternion;
    102     ToQuaternion(quaternion);
    103     return quaternion;
     97  Quaternion quaternion;
     98  ToQuaternion(quaternion);
     99  return quaternion;
    104100}
    105101
    106 float Euler::ToDegree(float radianValue) {
    107     return radianValue*180.0f/PI;
    108 }
     102float Euler::ToDegree(float radianValue) { return radianValue * 180.0f / PI; }
    109103
    110 float Euler::ToRadian(float degreeValue) {
    111     return degreeValue/180.0f*PI;
    112 }
     104float Euler::ToRadian(float degreeValue) { return degreeValue / 180.0f * PI; }
    113105
    114106float Euler::YawDistanceFrom(float angle) const {
    115     float rot1,rot2;
    116     if(angle > yaw ) {
    117         rot1=angle-yaw;
    118         rot2=2*PI-angle+yaw;
    119     } else {
    120         rot1=2*PI+angle-yaw;
    121         rot2=yaw-angle;
    122     }
    123     if(rot2<rot1) rot1=-rot2;
    124     rot1=-rot1;//pour avoir rot1=yaw-angle
     107  float rot1, rot2;
     108  if (angle > yaw) {
     109    rot1 = angle - yaw;
     110    rot2 = 2 * PI - angle + yaw;
     111  } else {
     112    rot1 = 2 * PI + angle - yaw;
     113    rot2 = yaw - angle;
     114  }
     115  if (rot2 < rot1)
     116    rot1 = -rot2;
     117  rot1 = -rot1; // pour avoir rot1=yaw-angle
    125118
    126     return rot1;
     119  return rot1;
    127120}
    128121
Note: See TracChangeset for help on using the changeset viewer.