Changeset 7184 for code/trunk
- Timestamp:
- Aug 18, 2010, 9:46:16 PM (14 years ago)
- Location:
- code/trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/util/ExprParser.cc
r6417 r7184 33 33 34 34 #include "ExprParser.h" 35 35 36 #include <cmath> 36 37 #include <cstring> 37 38 #include <cstdlib> 39 #include "Math.h" 38 40 39 41 // macros for easier if, else statements … … 50 52 { 51 53 this->failed_ = false; 52 this->variables_["pi"] = 3.1415926535897932;53 this->variables_["e"] = 2.7182818284590452;54 this->variables_["pi"] = math::pi_d; 55 this->variables_["e"] = math::e_d; 54 56 } 55 57 … … 328 330 value = sqrt(parse_last_argument()); 329 331 CASE("degrees") 330 value = parse_last_argument()*180/ 3.1415926535897932;332 value = parse_last_argument()*180/math::pi_d; 331 333 CASE("radians") 332 value = parse_last_argument()* 3.1415926535897932/180;334 value = parse_last_argument()*math::pi_d/180; 333 335 CASE("mod") 334 336 { -
code/trunk/src/libraries/util/Math.cc
r6417 r7184 185 185 float distancelength = distance.length(); 186 186 if (distancelength == 0) return orxonox::Vector2(0, 0); 187 float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / Ogre::Math::PI;187 float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / math::pi; 188 188 189 189 if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0) -
code/trunk/src/libraries/util/Math.h
r6502 r7184 59 59 namespace orxonox 60 60 { 61 // C++ doesn't define any constants for pi, e, etc. 62 namespace math 63 { 64 const float pi = 3.14159265f; 65 const float pi_2 = 1.57079633f; 66 const float pi_4 = 7.85398163e-1f; 67 const float e = 2.71828183f; 68 const float sqrt2 = 1.41421356f; 69 const float sqrt2_2 = 7.07106781e-1f; 70 71 const double pi_d = 3.14159265358979324; 72 const double pi_2_d = 1.57079632679489662; 73 const double pi_4_d = 7.85398163397448310e-1; 74 const double e_d = 2.71828182845904524; 75 const double sqrt2_d = 1.41421356237309505; 76 const double sqrt2_2_d = 7.07106781186547524e-1; 77 } 78 61 79 #if OGRE_VERSION < 0x010603 62 80 _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian); -
code/trunk/src/modules/designtools/CreateStars.cc
r7163 r7184 38 38 { 39 39 CreateFactory(CreateStars); 40 41 static const float pi = 3.14159265359f;42 40 43 41 CreateStars::CreateStars(BaseObject* creator) : BaseObject(creator) … … 90 88 while(1) 91 89 { 92 phi = rnd(2* pi);93 teta = rnd( pi);90 phi = rnd(2*math::pi); 91 teta = rnd(math::pi); 94 92 float random = rnd(1); 95 93 if(sin(teta)>random) break; -
code/trunk/src/modules/overlays/hud/HUDRadar.cc
r7163 r7184 174 174 // calc position on radar... 175 175 Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 176 coord *= Ogre::Math::PI/ 3.5f; // small adjustment to make it fit the texture176 coord *= math::pi / 3.5f; // small adjustment to make it fit the texture 177 177 it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f); 178 178 it->second->show(); -
code/trunk/src/orxonox/controllers/AIController.cc
r7168 r7184 220 220 this->moveToTargetPosition(); 221 221 222 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget( Ogre::Math::PI/ 20.0f))222 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 223 223 this->getControllableEntity()->fire(0); 224 224 } … … 253 253 this->moveToTargetPosition(); 254 254 255 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget( Ogre::Math::PI/ 20.0f))255 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 256 256 this->getControllableEntity()->fire(0); 257 257 } -
code/trunk/src/orxonox/controllers/ArtificialController.cc
r7183 r7184 847 847 Vector3 distanceCurrent = this->targetPosition_ - this->getControllableEntity()->getPosition(); 848 848 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 * Ogre::Math::PI))850 < this->targetPosition_.squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / (2 * Ogre::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()) / (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)) 851 851 { 852 852 this->target_ = (*it); -
code/trunk/src/orxonox/controllers/NewHumanController.cc
r7163 r7184 534 534 if (distance > 0.04f && distance <= 0.59f * arrowsSize_ / 2.0f ) 535 535 { 536 this->arrowsOverlay1_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));536 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)); 537 537 this->arrowsOverlay1_->show(); 538 538 } 539 539 else if (distance > 0.59f * arrowsSize_ / 2.0f && distance <= 0.77f * arrowsSize_ / 2.0f ) 540 540 { 541 this->arrowsOverlay2_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));541 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)); 542 542 this->arrowsOverlay2_->show(); 543 543 } 544 544 else if (distance > 0.77f * arrowsSize_ / 2.0f && distance <= arrowsSize_ / 2.0f) 545 545 { 546 this->arrowsOverlay3_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));546 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)); 547 547 this->arrowsOverlay3_->show(); 548 548 } 549 549 else if (distance > arrowsSize_ / 2.0f) 550 550 { 551 this->arrowsOverlay4_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * Ogre::Math::PI) * 360.0f));551 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)); 552 552 this->arrowsOverlay4_->show(); 553 553 } -
code/trunk/src/orxonox/controllers/WaypointPatrolController.cc
r7163 r7184 68 68 this->moveToTargetPosition(); 69 69 70 if (this->getControllableEntity() && this->isCloseAtTarget(1000) && this->isLookingAtTarget( Ogre::Math::PI/ 20.0f))70 if (this->getControllableEntity() && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 71 71 this->getControllableEntity()->fire(0); 72 72 } -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r6799 r7184 282 282 if (angle < 0.0) 283 283 angle = -angle; 284 angle -= Ogre::Math::PI * static_cast<int>(angle / (Ogre::Math::PI));285 if (angle > Ogre::Math::PI* 0.5)286 angle = Ogre::Math::PI- angle;284 angle -= math::pi * static_cast<int>(angle / (math::pi)); 285 if (angle > math::pi * 0.5) 286 angle = math::pi - angle; 287 287 288 288 // do some mathematical fiddling for a bounding box -
code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc
r7183 r7184 171 171 172 172 Radian pitch = this->cameraPositionRootNode_->getOrientation().getPitch(); 173 if (pitch < Radian( 1.5707f) && pitch > Radian(-1.5707f))173 if (pitch < Radian(math::pi_2) && pitch > Radian(-math::pi_2)) 174 174 { 175 175 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 176 176 } 177 else if (pitch < Radian(- 1.5707f))177 else if (pitch < Radian(-math::pi_2)) 178 178 { 179 179 if (this->pitch_ > 0.0f) 180 180 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 181 else if (pitch < Radian(- 1.571f))182 this->cameraPositionRootNode_->pitch(-pitch + Radian(- 1.570796f));181 else if (pitch < Radian(-math::pi_2)) 182 this->cameraPositionRootNode_->pitch(-pitch + Radian(-math::pi_2)); 183 183 } 184 else if (pitch > Radian( 1.5707f))184 else if (pitch > Radian(math::pi_2)) 185 185 { 186 186 if (this->pitch_ < 0.0f) 187 187 this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 188 else if (pitch > Radian( 1.571f))189 this->cameraPositionRootNode_->pitch(-pitch + Radian( 1.570796f));188 else if (pitch > Radian(math::pi_2)) 189 this->cameraPositionRootNode_->pitch(-pitch + Radian(math::pi_2)); 190 190 } 191 191 this->weaponNode_->setOrientation(this->cameraPositionRootNode_->getOrientation());
Note: See TracChangeset
for help on using the changeset viewer.