Changeset 708 for code/branches/FICN/src/orxonox/Arrival.h
- Timestamp:
- Dec 28, 2007, 10:30:29 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/Arrival.h
r673 r708 6 6 #define _Arrival_H__ 7 7 8 // #include <Ogre.h> 9 #include <OgreVector3.h>8 #include "misc/Vector3.h" 9 #include "misc/Quaternion.h" 10 10 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 11 namespace orxonox 12 { 13 class Arrival 14 { 20 15 public: 21 16 Vector3 location; //!< locationvector of the element … … 27 22 28 23 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 } 35 30 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 } 42 37 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 } 49 44 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 } 53 48 54 Vector3 getDirection() {55 Vector3 direction = target-location;56 }49 Vector3 getDirection() { 50 Vector3 direction = target-location; 51 } 57 52 58 double relativeDirectApproach() {59 // Maxspeed / accelerationForwards = time needed to break with max acceleration60 // 2*getDistance()length/(MaxSpeed/accelerationForwards)^2 = required acceleration to arrive at the target with speed = 061 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 } 63 58 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 } 73 75 } 74 76 else { 75 // speed will stay constant76 77 } 77 78 79 }80 else {81 82 83 78 } 84 79 85 } 80 }; 86 81 } 87 82
Note: See TracChangeset
for help on using the changeset viewer.