-
Notifications
You must be signed in to change notification settings - Fork 0
/
physobj.h
100 lines (86 loc) · 2.36 KB
/
physobj.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* =====================================================================================
*
* Filename: physobj.h
*
* Description: physical object
*
* Version: 1.0
* Created: 13.03.2017 19:50:00
* Revision: none
* Compiler: gcc
*
* Author: Arvid Krein (mn), arvid2000@googlemail.com
* Company: -
*
* =====================================================================================
*/
#ifndef PHYSOBJ
#define PHYSOBJ
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include "physobj.h"
#include "vec2.h"
class physobj
{
public:
float getX() const;
float getY() const;
int setX(float x);
int setY(float y);
float getxvel() const;
float getyvel() const;
int setxvel(float x);
int setyvel(float y);
physobj(float x=0, float y=0, float vx=0, float vy=0);
~physobj();
vec2 pos;
vec2 vel;
std::array<unsigned short,4> color = {0x00,0x00,0x00,0xFF};
private:
};
class kraftpartikel : public physobj
{
public:
kraftpartikel(float x = 0, float y = 0, float mass = 1, float charge = 1);
void iterate(float t);
float getFx() const; //get methods
float getFy() const;
float getMass() const;
float getCharge() const;
void setFx(float F); //set methods
void setFy(float F);
void setMass(float m);
void setCharge(float q);
vec2 F;
private:
float mMass=1;
float mCharge=1;
};
class Worldframe
{
public:
void iterate(float t);
Worldframe(float coulombfaktor, float gravFx, float gravFy);
Worldframe();
~Worldframe();
vec2 size;
vec2 gravF;
float coulombfaktor = 40000;
float getEnergy();
std::vector<kraftpartikel> vKPartikel;
int bouncetype = 1;
private:
void radialForce(kraftpartikel* part1, kraftpartikel* part2, float kraftfaktor, float exponent); //radialkraft part2 auf part1. Form: F^{->} = e^{^}_{r} * kraftfaktor * r^{exponent}
void elasticBounce(kraftpartikel* part1, kraftpartikel* part2);
void gravitationalForce(kraftpartikel* part, float Fx, float Fy); //In bestimmte Richtung gerichtete kraft.
bool collisioncheck(physobj* part1, physobj* part2);
bool isoutofworld(const physobj& part) const;
void periodicboundary(physobj* part);
void wallbounce(physobj* part);
};
#endif