bin auf falschen branch, sollte A5 sein
This commit is contained in:
parent
a7a85287d0
commit
09c8ca75fe
@ -4,4 +4,38 @@
|
|||||||
#include "flugkurve03.h"
|
#include "flugkurve03.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//to be implemented
|
|
||||||
|
Vektor Vektor::mulVektor(const Vektor &vec, const float &skalar){
|
||||||
|
Vektor ergebnis = {vec.x * skalar, vec.y * skalar};
|
||||||
|
return ergebnis;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vektor addVektor(const Vektor &vec1, const Vektor &vec2) {
|
||||||
|
Vektor erg = {x + x, y + y};
|
||||||
|
return erg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Koerper bewegeKoerper(const Koerper &korp, const Vektor &gesamtkraft,const float &dt) {
|
||||||
|
Koerper erg = {0, {0,0}, {0,0}};
|
||||||
|
// Berechnung der Beschleunigung aus der Kraft
|
||||||
|
const float xBeschleunigung = gesamtkraft.x / korp.masse;
|
||||||
|
const float yBeschleunigung = gesamtkraft.y / korp.masse;
|
||||||
|
|
||||||
|
// Ermittlung der neuen Geschwindigkeit
|
||||||
|
erg.geschwindigkeit.x = korp.geschwindigkeit.x + dt * xBeschleunigung;
|
||||||
|
erg.geschwindigkeit.y = korp.geschwindigkeit.y + dt * yBeschleunigung;
|
||||||
|
|
||||||
|
// Ermittlung der neuen Position
|
||||||
|
erg.position.x += korp.position.x + dt * erg.geschwindigkeit.x;
|
||||||
|
erg.position.y += korp.position.y + dt * erg.geschwindigkeit.y;
|
||||||
|
return erg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ausgabeKoerper(const Koerper &korp){
|
||||||
|
cout << "x = " << korp.position.x << "y = " << korp.position.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ausgabeVektor(const Vektor &vec){
|
||||||
|
cout << "x = " << vec.x << endl;
|
||||||
|
cout << "y = " << vec.y << endl;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,38 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// to be defined
|
#pragma once
|
||||||
|
|
||||||
|
// Parametrierung der auf den Körper wirkende Kräfte:
|
||||||
|
class Vektor {
|
||||||
|
public:
|
||||||
|
float x; // [m/s^2]
|
||||||
|
float y; // [m/s^2]
|
||||||
|
Vektor() = default;
|
||||||
|
Vektor(float x, float y) {
|
||||||
|
this->x = x;
|
||||||
|
this->y = y;
|
||||||
|
}
|
||||||
|
void add(const Vektor &vec2);
|
||||||
|
void ausgabeVektor(const Vektor &vec);
|
||||||
|
void mul(const float &skalar);
|
||||||
|
};
|
||||||
|
// Körper:
|
||||||
|
class Koerper {
|
||||||
|
float masse; // [kg]
|
||||||
|
Vektor position;
|
||||||
|
Vektor geschwindigkeit;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Koerper(float masse, Vektor position, Vektor geschwindigkeit) {
|
||||||
|
this->masse = masse;
|
||||||
|
this->position = position;
|
||||||
|
this->geschwindigkeit = geschwindigkeit;
|
||||||
|
};
|
||||||
|
float liefereMasse();
|
||||||
|
Koerper bewegeKoerper(const Koerper &korp, const Vektor &gesamtkraft,
|
||||||
|
const float &dt);
|
||||||
|
Vektor lieferePosition();
|
||||||
|
Vektor liefereGeschwindigkeit();
|
||||||
|
void bewegen(Vektor beschleunigung, float dt);
|
||||||
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user