Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/shader/src/asylum/orxonox/Arrival.h @ 10255

Last change on this file since 10255 was 1505, checked in by rgrieder, 17 years ago

f* svn: It doesn't even inform you if you attempt to set a non existing property. It is svn:eol-style and not eol-style when using the command by the way…

  • Property svn:eol-style set to native
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.