Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/Arrival.h @ 771

Last change on this file since 771 was 742, checked in by landauf, 17 years ago

moved all files from misc and the tinyxml folder into the new util folder

File size: 2.1 KB
Line 
1
2// Arrival Class
3
4
5#ifndef _Arrival_H__
6#define _Arrival_H__
7
8#include "util/Math.h"
9
10namespace orxonox
11{
12  class Arrival
13  {
14  public:
15    Vector3 location;           //!< locationvector of the element
16    Vector3 speed;              //!< speedvector of the element
17    Vector3 acceleration;       //!< accelerationvector of the element
18    Vector3 target;             //!< target to arrive
19    int accelerationForwards;   //!< from steering-interface
20    int MaxSpeed;               //!< from steering-interface
21
22
23    Arrival() {
24      acceleration = (0,0,0);
25      speed = (0,0,0);
26      location = (0,0,0);
27      target = (0,0,0);
28    }
29
30    Arrival(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
31      acceleration = acceleration_;
32      speed = speed_;
33      location = location_;
34      target = target_;
35    }
36
37    void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
38      acceleration = acceleration_;
39      speed = speed_;
40      location = location_;
41      target = target_;
42    }
43
44    void setTarget(Vector3 target_) {
45      setValues(this->location, this->speed, this->acceleration, target_);
46    }
47
48    Vector3 getDirection() {
49      Vector3 direction = target-location;
50    }
51
52    double relativeDirectApproach() {
53      // Maxspeed / accelerationForwards = time needed to break with max acceleration
54      // 2*getDistance()length/(MaxSpeed/accelerationForwards)^2 = required acceleration to arrive at the target with speed = 0
55      return (accelerationForwards / (2*getDirection().length() / ((MaxSpeed/accelerationForwards)*(MaxSpeed/accelerationForwards))) );
56    }
57
58    void Approach() {
59      Quaternion rotation = Quaternion(0,0,0,0);
60      if (relativeDirectApproach() > 1)
61      {
62        float length = speed.length();
63        speed = (speed+getDirection());
64        speed.normalise();
65        speed = speed*length;
66        if (relativeDirectApproach() > 4)
67        {
68          //accelerate
69        }
70        else
71        {
72          // speed will stay constant
73        }
74      }
75      else {
76      }
77    }
78
79  };
80}
81
82#endif /* _Arrival_H__ */
Note: See TracBrowser for help on using the repository browser.