Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 28, 2007, 10:30:29 PM (16 years ago)
Author:
rgrieder
Message:
  • added Vector2, Vector3, Matrix3, ColourValue, Quaternion and String to the misc folder as header files (each of them contains #include <string> … typedef std::string String , etc.)
  • please use String from now on by including <misc/String.h"
  • removed #include <OgreVector3.h", etc. from "CoreIncludes.h" (adjusted all source files)
  • adjusted all the source files (except network, that keeps <string> for the moment) (what a mess..)
  • moved usleep hack to misc/Sleep.h
  • relative include paths for files from other root directories (like misc, network, etc.) (but it stills writes "../Orxonox.h" when in folder orxonox/objects)
  • "OgreSceneManager.h" —> <OgreSceneManager.h>
  • included OrxonoxPrereqs in every file in folder orxonox
  • moved HUD and ParticleInterface to namespace orxonox
  • removed some using namespace Ogre/std when appropriate
  • I hope I haven't forgotten important points..
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/Arrival.h

    r673 r708  
    66#define _Arrival_H__
    77
    8 // #include <Ogre.h>
    9 #include <OgreVector3.h>
     8#include "misc/Vector3.h"
     9#include "misc/Quaternion.h"
    1010
    11 
    12 #include <iostream>
    13 
    14 // FIXME: using namspace xy; in header files is a bad idea
    15 using namespace std;
    16 using namespace Ogre;
    17 
    18 class Arrival {
    19 
     11namespace orxonox
     12{
     13  class Arrival
     14  {
    2015  public:
    2116    Vector3 location;           //!< locationvector of the element
     
    2722
    2823
    29   Arrival() {
    30     acceleration = (0,0,0);
    31     speed = (0,0,0);
    32     location = (0,0,0);
    33     target = (0,0,0);
    34   }
     24    Arrival() {
     25      acceleration = (0,0,0);
     26      speed = (0,0,0);
     27      location = (0,0,0);
     28      target = (0,0,0);
     29    }
    3530
    36   Arrival(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
    37     acceleration = acceleration_;
    38     speed = speed_;
    39     location = location_;
    40     target = target_;
    41   }
     31    Arrival(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
     32      acceleration = acceleration_;
     33      speed = speed_;
     34      location = location_;
     35      target = target_;
     36    }
    4237
    43   void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
    44     acceleration = acceleration_;
    45     speed = speed_;
    46     location = location_;
    47     target = target_;
    48   }
     38    void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
     39      acceleration = acceleration_;
     40      speed = speed_;
     41      location = location_;
     42      target = target_;
     43    }
    4944
    50   void setTarget(Vector3 target_) {
    51     setValues(this.location, this.speed, this.acceleration, target_);
    52   }
     45    void setTarget(Vector3 target_) {
     46      setValues(this->location, this->speed, this->acceleration, target_);
     47    }
    5348
    54   Vector3 getDirection() {
    55     Vector3 direction = target-location;
    56   }
     49    Vector3 getDirection() {
     50      Vector3 direction = target-location;
     51    }
    5752
    58   double relativeDirectApproach() {
    59     // Maxspeed / accelerationForwards = time needed to break with max acceleration
    60     // 2*getDistance()length/(MaxSpeed/accelerationForwards)^2 = required acceleration to arrive at the target with speed = 0
    61     return (accelerationForwards / (2*getDirection().length / (MaxSpeed/accelerationForwards)^2) );
    62   }
     53    double relativeDirectApproach() {
     54      // Maxspeed / accelerationForwards = time needed to break with max acceleration
     55      // 2*getDistance()length/(MaxSpeed/accelerationForwards)^2 = required acceleration to arrive at the target with speed = 0
     56      return (accelerationForwards / (2*getDirection().length() / ((MaxSpeed/accelerationForwards)*(MaxSpeed/accelerationForwards))) );
     57    }
    6358
    64   void Approach() {
    65     Quaternion rotation = (0,0,0,0);
    66     if (relativeDirectApproach() > 1) {
    67       float length = speed.length();
    68       speed = (speed+getDirection());
    69       speed.normalise();
    70       speed = speed*length;
    71       if (relativeDirectApproach > 4) {
    72         //accelerate
     59    void Approach() {
     60      Quaternion rotation = Quaternion(0,0,0,0);
     61      if (relativeDirectApproach() > 1)
     62      {
     63        float length = speed.length();
     64        speed = (speed+getDirection());
     65        speed.normalise();
     66        speed = speed*length;
     67        if (relativeDirectApproach() > 4)
     68        {
     69          //accelerate
     70        }
     71        else
     72        {
     73          // speed will stay constant
     74        }
    7375      }
    7476      else {
    75         // speed will stay constant
    7677      }
    77 
    78 
    79     }
    80     else {
    81 
    82 
    8378    }
    8479
    85   }
     80  };
    8681}
    8782
Note: See TracChangeset for help on using the changeset viewer.