Aufgabe 3-5

This commit is contained in:
2026-04-15 20:25:59 +02:00
parent 3442cc5697
commit 65abdc34a9
8 changed files with 184 additions and 12 deletions
+50 -1
View File
@@ -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();
}
+28 -1
View File
@@ -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();
};