Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

ss16:physiksimulation_doc_cpp

Dies ist eine alte Version des Dokuments!


Hauptseite des Projekts

zurück zur Liste der Komponenten

Physiksimulation | C++-Teil

INFO: Soweit nicht anders angegeben, sind die Code-Bestandteile auf dieser Seite aus den jeweiligen Header-Dateien.

Programmstruktur

vector3d.cpp

Die Klasse Vector3D ist die Grundlage für alle Größen der Berechnungen wie Positionen, Geschwindigkeiten, Beschleunigungen und Kräfte.
Unser Vector3D bietet folgende Funktionalitäten:

class Vector3D
{
    private:
    // DEKLARATION DER ATTRIBUTE
        double x,y,z;
 
    public:
    // KONSTRUKTOREN
        Vector3D();
        Vector3D(double, double, double);
 
    // GETTER
        double getX() const;
        double getY() const;
        double getZ() const;
 
    // SETTER
        void setX(double);
        void setY(double);
        void setZ(double);
 
    // OPERATORUEBERLADUNGEN
        Vector3D operator+(const Vector3D &a) const;
        Vector3D operator-(const Vector3D &a) const;
        Vector3D operator*(const double) const;
        Vector3D operator/(double) const;
        bool     operator== (const Vector3D) const;
 
 
    // SONSTIGE FUNKTIONEN
        double betrag();
        double skalarprodukt(Vector3D &a);
        double winkel(Vector3D &a);
        double abstand (const Vector3D &a);
        Vector3D kreuzprodukt(Vector3D &a) const; 
        double spatprodukt(Vector3D &a, Vector3D &b);
        Vector3D norm();
        std::string asString() const;
};

object.cpp

Unsere Objects dienen der Aufbewahrung der Werte, die für die Berechnungen wichtig sind sowie einen Namen zur Identifikation.

#include "vector3d.hpp"
 
class Object
{
    private:
    // DEKLARATION DER ATTRIBUTE
        std::string name;
        Vector3D pos;   // Position
        Vector3D vel;   // Velocity
        Vector3D acc;   // Acceleration
        double   vol;   // Volume
        double   den;   // Density
        double 	 mas;	// Mass
        bool     fix;   // is fixed?
 
    public:
    // KONSTRUKTOREN
        Object (std::string);
        Object (Vector3D, Vector3D);
        Object (Vector3D, Vector3D, Vector3D);
 
    // GETTER
        std::string getName() const;
        Vector3D getPos()  const;
        Vector3D getVel()  const;
        Vector3D getAcc()  const;
        double   getVol()  const;
        double   getDen()  const;
        double   getMass() const;
        bool     isFixed() const;
 
    // SETTER
        void setPos (Vector3D);
        void setVel (Vector3D);
        void setAcc (Vector3D);
        void setVol (double);
        void setDen (double);
        void setMass(double);
        void setFix (bool);
 
    // OPERATOR OVERLOADINGS
        bool operator== (Object*) const;
 
};
ss16/physiksimulation_doc_cpp.1471104334.txt.gz · Zuletzt geändert: 2016/08/13 18:05 von markumnus