added comments and smaller improvements
This commit is contained in:
parent
85744e9e1b
commit
5ed61b47d5
11 changed files with 28 additions and 14 deletions
Binary file not shown.
|
@ -54,7 +54,7 @@ Vektor Vektor::rotate(Vektor v, double angle)
|
|||
{0, 0, 1}
|
||||
};
|
||||
|
||||
/* Matrix Multiplikation */
|
||||
/* Matrix Multiplikation + Runden */
|
||||
return *new Vektor(
|
||||
round(1000 * (L[0][0] * v.getX() + L[0][1] * v.getY() + L[0][2] * v.getZ())) / 1000,
|
||||
round(1000 * (L[1][0] * v.getX() + L[1][1] * v.getY() + L[1][2] * v.getZ())) / 1000,
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
void ausgabe();
|
||||
|
||||
private:
|
||||
//member
|
||||
// members
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
|
|
|
@ -4,16 +4,19 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
/* create Vektor instances */
|
||||
Vektor v1(1, -2, 3);
|
||||
Vektor v2(9.9, 0, 6);
|
||||
Vektor v3(4.1, 9.2, -2.3);
|
||||
Vektor v4 = Vektor::add(v1, v2);
|
||||
|
||||
/* print Vektors */
|
||||
std::cout << "v1 = "; v1.ausgabe();
|
||||
std::cout << "v2 = "; v2.ausgabe();
|
||||
std::cout << "v3 = "; v3.ausgabe();
|
||||
std::cout << "v4 = "; v4.ausgabe();
|
||||
|
||||
/* vector calculus */
|
||||
v3.substract(v4);
|
||||
std::cout << std::endl << "v3-4 = "; v3.ausgabe();
|
||||
|
||||
|
@ -23,18 +26,25 @@ int main()
|
|||
|
||||
std::cout << std::endl << "Rotate pi/2 ccw: v2' = "; Vektor::rotate(v2, M_PI/2).ausgabe();
|
||||
std::cout << "Rotate 52° ccw: v2'' = "; Vektor::rotate(v2, 52*M_PI/180).ausgabe();
|
||||
std::cout << std::endl;
|
||||
|
||||
/* Teilaufgabe 3: Berechnung der Sichtweite */
|
||||
double radius = 6371000;
|
||||
double size1 = 1.8;
|
||||
double size2 = 830;
|
||||
Vektor v5(0, radius + size1, 0);
|
||||
Vektor v6(0, radius + size2, 0);
|
||||
double sizes[2] = {1.8, 830};
|
||||
|
||||
std::cout << std::endl << "Sichtweite bei " << size1 << "m über der Meeresoberfläche: "
|
||||
<< -Vektor::rotate(v5, acos(radius / (radius + size1))).getX() / 1000 << "km" << std::endl;
|
||||
std::cout << "Sichtweite bei " << size2 << "m über der Meeresoberfläche: "
|
||||
<< -Vektor::rotate(v6, acos(radius / (radius + size2))).getX() / 1000 << "km" << std::endl;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Vektor v5(0, radius + sizes[i], 0);
|
||||
|
||||
/* Vektoren drehen */
|
||||
Vektor v6 = Vektor::rotate(v5, acos(radius / (radius + sizes[i])));
|
||||
|
||||
/* Differenz bilden */
|
||||
Vektor v7(v6.getX(),v6.getY() - radius, v6.getZ());
|
||||
|
||||
std::cout << "Sichtweite bei " << sizes[i] << "m über der Meeresoberfläche: "
|
||||
<< v7.getLength() / 1000 << "km" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -4,8 +4,9 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream> // um double in string umzuwandeln.
|
||||
|
||||
/**
|
||||
* Abstrakte Interface Klasse
|
||||
* (Abstrakte) Interface Klasse
|
||||
*/
|
||||
class Expression
|
||||
{
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
|
||||
int main(int, char**)
|
||||
{
|
||||
/* initialize expressions */
|
||||
Result result1(new Mul(new Const(3), new Add(new Const(2), new Const(9))));
|
||||
Result result2(new Div(new Const(3), new Const(4)));
|
||||
Result result3(new Div(new Const(3), new Sub(new Const(4), new Mul(new Const(1.2), new Const(3)))));
|
||||
|
||||
/* print results */
|
||||
std::cout << result1.print() << " = " << result1.evaluate() << std::endl;
|
||||
std::cout << result2.print() << " = " << result2.evaluate() << std::endl;
|
||||
std::cout << result3.print() << " = " << result3.evaluate() << std::endl;
|
||||
|
|
|
@ -77,7 +77,7 @@ bool StackSpeicher<size, T>::pop(T& e)
|
|||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Sortieren
|
||||
// Sortieren mit Quicksort
|
||||
template<int size, class T>
|
||||
void StackSpeicher<size, T>::sort(int start = 0, int ende = -1)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ using namespace std;
|
|||
|
||||
int main()
|
||||
{
|
||||
/* instantiate students */
|
||||
/* create students */
|
||||
Student stud1(22222, "Born" ,"Jessica", "16.03.1986");
|
||||
Student stud2(24528, "Rodenstock","Max" , "09.02.1985");
|
||||
Student stud3(95420, "Schneider" ,"Petra" , "29.12.1989");
|
||||
|
|
Binary file not shown.
|
@ -39,9 +39,10 @@ int main()
|
|||
students.push_back(stud7);
|
||||
students.push_back(stud8);
|
||||
|
||||
/* use std::algorithms to sort vector */
|
||||
sort(students.begin(), students.end());
|
||||
|
||||
/* output again */
|
||||
/* iterate over vector and print */
|
||||
for (vector<Student>::iterator it = students.begin(); it != students.end(); ++it)
|
||||
{
|
||||
cout << *it;
|
||||
|
|
Loading…
Add table
Reference in a new issue