diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Real-Time Systems/RTS_A8/src/POS.h | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Master/Real-Time Systems/RTS_A8/src/POS.h')
| -rw-r--r-- | Master/Real-Time Systems/RTS_A8/src/POS.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/Master/Real-Time Systems/RTS_A8/src/POS.h b/Master/Real-Time Systems/RTS_A8/src/POS.h new file mode 100644 index 0000000..490838a --- /dev/null +++ b/Master/Real-Time Systems/RTS_A8/src/POS.h @@ -0,0 +1,69 @@ +/* + * POS.h + * + * Created on: 30.11.2010 + * Author: istsveise + */ + +#ifndef POS_H_ +#define POS_H_ + +#include <iostream> +#include <cmath> + +using namespace std; + +extern const double PI; + +struct vector3d { + double x; + double y; + double z; + vector3d(double px,double py):x(px),y(py),z(1) {}; + vector3d():x(0),y(0),z(1) {}; + double length() { + return sqrt( (x*x) + (y*y) ); + } + double scalarProduct(const vector3d& l) { + return (x*l.x)+(y*l.y)+(z*l.z); + } + void crossProduct(const vector3d& l,vector3d& res) + { + res.x = ( (y*l.z) - (z*l.y) ); + res.y = ( (z*l.x) - (x*l.z) ); + res.z = ( (x*l.y) - (y*l.x) ); + } + void normalize() + { + double len = length(); + x = x / len; + y = y / len; + z = z / len; + } +}; + +struct POS { + double x; + double y; + void move(double v, double dir) + { +// cout << "v: " << v << " dir: " << dir <<endl; + double dx = v * cos(dir*PI/180); + double dy = v * sin(dir*PI/180); +// cout << "dx: " << dx << " dy: " << dy <<endl; + x += dx; + y += dy; + } + void display(const char* prefix) { + cout << prefix << " "<< x << " " << y << endl; + } +}; + +#ifndef ABSTAND +#define ABSTAND + +extern double Abstand(POS p,double Ldir); + +#endif + +#endif /* POS_H_ */ |
