Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8333


Ignore:
Timestamp:
Apr 26, 2011, 4:46:26 AM (13 years ago)
Author:
rgrieder
Message:

Removed double precision versions of the mathematical constants and added math::twoPi.

Location:
code/branches/kicklib2/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib2/src/libraries/util/Math.h

    r7427 r8333  
    6666namespace orxonox
    6767{
    68     // C++ doesn't define any constants for pi, e, etc.
     68    /** Often used numerical constants because C++ doesn't define any.
     69    @note
     70        The values here are decimal representations of the approximate floating
     71        point value as it is stored according to the IEEE 754 standard.
     72    */
    6973    namespace math
    7074    {
    71         const float pi      = 3.14159265f;      ///< PI
    72         const float pi_2    = 1.57079633f;      ///< PI / 2
    73         const float pi_4    = 7.85398163e-1f;   ///< PI / 4
    74         const float e       = 2.71828183f;      ///< e
    75         const float sqrt2   = 1.41421356f;      ///< sqrt(2)
    76         const float sqrt2_2 = 7.07106781e-1f;   ///< sqrt(2) / 2
    77 
    78         const double pi_d      = 3.14159265358979324;       ///< PI (double)
    79         const double pi_2_d    = 1.57079632679489662;       ///< PI / 2 (double)
    80         const double pi_4_d    = 7.85398163397448310e-1;    ///< PI / 4 (double)
    81         const double e_d       = 2.71828182845904524;       ///< e (double)
    82         const double sqrt2_d   = 1.41421356237309505;       ///< sqrt(2) (double)
    83         const double sqrt2_2_d = 7.07106781186547524e-1;    ///< sqrt(2) / 2 (double)
     75        const float twoPi   = 6.283185482025146484375f;     ///< PI * 2
     76        const float pi      = 3.1415927410125732421875f;    ///< PI
     77        const float pi_2    = 1.57079637050628662109375f;   ///< PI / 2
     78        const float pi_4    = 0.785398185253143310546875f;  ///< PI / 4
     79        const float e       = 2.718281269073486328125f;     ///< e
     80        const float sqrt2   = 1.41421353816986083984375f;   ///< sqrt(2)
     81        const float sqrt2_2 = 0.707106769084930419921875f;  ///< sqrt(2) / 2
    8482    }
    8583
  • code/branches/kicklib2/src/modules/designtools/CreateStars.cc

    r7184 r8333  
    8888            while(1)
    8989            {
    90                 phi = rnd(2*math::pi);
     90                phi = rnd(math::twoPi);
    9191                teta = rnd(math::pi);
    9292                float random = rnd(1);
  • code/branches/kicklib2/src/orxonox/controllers/ArtificialController.cc

    r7801 r8333  
    847847                Vector3 distanceCurrent = this->targetPosition_ - this->getControllableEntity()->getPosition();
    848848                Vector3 distanceNew = it->getPosition() - this->getControllableEntity()->getPosition();
    849                 if (!this->target_ || it->getPosition().squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceNew) / speed / distanceNew.length()) / (2 * math::pi))
    850                         < this->targetPosition_.squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / (2 * math::pi)) + rnd(-250, 250))
     849                if (!this->target_ || it->getPosition().squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceNew) / speed / distanceNew.length()) / math::twoPi)
     850                        < this->targetPosition_.squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / math::twoPi) + rnd(-250, 250))
    851851                {
    852852                    this->target_ = (*it);
  • code/branches/kicklib2/src/orxonox/controllers/NewHumanController.cc

    r7859 r8333  
    543543            if (distance > 0.04f && distance <= 0.59f * arrowsSize_ / 2.0f )
    544544            {
    545                 this->arrowsOverlay1_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * math::pi) * 360.0f));
     545                this->arrowsOverlay1_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / math::twoPi * 360.0f));
    546546                this->arrowsOverlay1_->show();
    547547            }
    548548            else if (distance > 0.59f * arrowsSize_ / 2.0f && distance <= 0.77f * arrowsSize_ / 2.0f )
    549549            {
    550                 this->arrowsOverlay2_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * math::pi) * 360.0f));
     550                this->arrowsOverlay2_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / math::twoPi * 360.0f));
    551551                this->arrowsOverlay2_->show();
    552552            }
    553553            else if (distance > 0.77f * arrowsSize_ / 2.0f && distance <= arrowsSize_ / 2.0f)
    554554            {
    555                 this->arrowsOverlay3_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * math::pi) * 360.0f));
     555                this->arrowsOverlay3_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / math::twoPi * 360.0f));
    556556                this->arrowsOverlay3_->show();
    557557            }
    558558            else if (distance > arrowsSize_ / 2.0f)
    559559            {
    560                 this->arrowsOverlay4_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * math::pi) * 360.0f));
     560                this->arrowsOverlay4_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / math::twoPi * 360.0f));
    561561                this->arrowsOverlay4_->show();
    562562            }
  • code/branches/kicklib2/src/orxonox/graphics/BlinkingBillboard.cc

    r8332 r8333  
    8181            // Wrap around to avoid loosing floating point precision
    8282            this->time_ = std::fmod(this->time_ + dt, 1.0f / this->frequency_);
    83             float value = sin((2.0f * math::pi * this->time_ + this->phase_.valueRadians()) * this->frequency_);
     83            float value = sin((math::twoPi * this->time_ + this->phase_.valueRadians()) * this->frequency_);
    8484            if (this->bQuadratic_)
    8585                this->setScale(this->amplitude_ * square(value));
  • code/branches/kicklib2/src/orxonox/overlays/OrxonoxOverlay.cc

    r7401 r8333  
    283283            angle = -angle;
    284284        angle -= math::pi * static_cast<int>(angle / (math::pi));
    285         if (angle > math::pi * 0.5)
     285        if (angle > math::pi_2)
    286286            angle = math::pi - angle;
    287287
Note: See TracChangeset for help on using the changeset viewer.