-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathParticle.h
97 lines (76 loc) · 1.37 KB
/
Particle.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
#pragma once
#include <Eigen/Core.h>
#include "SmartPointer.h"
#include "AbstractShape.h"
class Particle
{
public:
Particle(sp<AbstractShape> shape)
{
Reset();
m_shape = shape;
}
Particle(Eigen::Vector2f initialPosition, sp<AbstractShape> shape)
{
Reset();
m_shape = shape;
m_position = initialPosition;
}
void SetPosition(Eigen::Vector2f newPosition)
{
m_position = newPosition;
}
void SetVelocity(Eigen::Vector2f newVelocity)
{
m_velocity = newVelocity;
}
void SetAcceleration(Eigen::Vector2f newAcceleration)
{
m_acceleration = newAcceleration;
}
Eigen::Vector2f GetPosition()
{
return m_position;
}
Eigen::Vector2f GetVelocity()
{
return m_velocity;
}
Eigen::Vector2f GetAcceleration()
{
return m_acceleration;
}
int GetAge()
{
return m_age;
}
sp<AbstractShape> GetShape()
{
return m_shape;
}
void Tick()
{
auto test = m_acceleration[0];
test = m_acceleration[1];
m_velocity += m_acceleration;
m_position += m_velocity;
m_shape->SetPosition(Point(m_position[0], m_position[1]));
m_age++;
}
private:
void Reset()
{
m_age = 0;
m_position[0] = 0;
m_position[1] = 0;
m_velocity[0] = 0;
m_velocity[1] = 0;
m_acceleration[0] = 0;
m_acceleration[1] = 0;
}
int m_age;
sp<AbstractShape> m_shape;
Eigen::Vector2f m_position;
Eigen::Vector2f m_velocity;
Eigen::Vector2f m_acceleration;
};