Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/Arrival.h @ 843

Last change on this file since 843 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

File size: 2.1 KB
RevLine 
[597]1
2// Arrival Class
3
4
[673]5#ifndef _Arrival_H__
6#define _Arrival_H__
[597]7
[742]8#include "util/Math.h"
[597]9
[708]10namespace orxonox
11{
12  class Arrival
13  {
[597]14  public:
[618]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
[597]21
22
[708]23    Arrival() {
24      acceleration = (0,0,0);
25      speed = (0,0,0);
26      location = (0,0,0);
27      target = (0,0,0);
28    }
[597]29
[708]30    Arrival(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
31      acceleration = acceleration_;
32      speed = speed_;
33      location = location_;
34      target = target_;
35    }
[597]36
[708]37    void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
38      acceleration = acceleration_;
39      speed = speed_;
40      location = location_;
41      target = target_;
42    }
[597]43
[708]44    void setTarget(Vector3 target_) {
45      setValues(this->location, this->speed, this->acceleration, target_);
46    }
[597]47
[708]48    Vector3 getDirection() {
49      Vector3 direction = target-location;
50    }
[597]51
[708]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    }
[597]57
[708]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        }
[597]74      }
75      else {
76      }
77    }
78
[708]79  };
[673]80}
81
[742]82#endif /* _Arrival_H__ */
Note: See TracBrowser for help on using the repository browser.