Aufgabe 3-5
This commit is contained in:
@@ -4,4 +4,53 @@
|
||||
#include "flugkurve03.h"
|
||||
using namespace std;
|
||||
|
||||
//to be implemented
|
||||
Vektor Vektor::mul(const float &skalar)
|
||||
{
|
||||
this->x *= skalar;
|
||||
this->y *= skalar;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vektor Vektor::add(const Vektor &vektor_to_add)
|
||||
{
|
||||
this->x += vektor_to_add.x;
|
||||
this->y += vektor_to_add.y;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Koerper Koerper::bewegen(const Vektor &beschleunigung, const float &dt)
|
||||
{
|
||||
this->position.x += this->geschwindigkeit.x * dt;
|
||||
this->position.y += this->geschwindigkeit.y * dt;
|
||||
|
||||
this->geschwindigkeit.x += beschleunigung.x * dt;
|
||||
this->geschwindigkeit.y += beschleunigung.y * dt;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vektor Koerper::liefereGeschwindigkeit()
|
||||
{
|
||||
return this->geschwindigkeit;
|
||||
}
|
||||
|
||||
Vektor Koerper::lieferePosition()
|
||||
{
|
||||
return this->position;
|
||||
}
|
||||
|
||||
float Koerper::liefereMasse()
|
||||
{
|
||||
return this->masse;
|
||||
}
|
||||
|
||||
string Koerper::text()
|
||||
{
|
||||
stringstream ausgabe;
|
||||
|
||||
ausgabe << "(" << this->position.x << "," << this->position.y << ")";
|
||||
|
||||
return ausgabe.str();
|
||||
}
|
||||
@@ -1,4 +1,31 @@
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
// to be defined
|
||||
class Vektor{
|
||||
public:
|
||||
float x;
|
||||
float y;
|
||||
|
||||
Vektor() : x(0), y(0) {}
|
||||
Vektor(float x, float y) : x(x), y(y) {}
|
||||
|
||||
Vektor mul(const float &skalar);
|
||||
Vektor add(const Vektor &vektor_to_add);
|
||||
};
|
||||
|
||||
class Koerper{
|
||||
public:
|
||||
|
||||
float masse;
|
||||
Vektor position;
|
||||
Vektor geschwindigkeit;
|
||||
|
||||
Koerper() : masse(0), position(0,0), geschwindigkeit(0,0){}
|
||||
Koerper(float m, Vektor pos, Vektor gesch) : masse(m), position(pos), geschwindigkeit(gesch) {}
|
||||
|
||||
Koerper bewegen(const Vektor &beschleunigung, const float &dt);
|
||||
Vektor liefereGeschwindigkeit();
|
||||
Vektor lieferePosition();
|
||||
float liefereMasse();
|
||||
string text();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user