-
Notifications
You must be signed in to change notification settings - Fork 13
/
subject.cpp
96 lines (76 loc) · 1.63 KB
/
subject.cpp
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
// Corona Simulation - basic simulation of a human transmissable virus
// Copyright (C) 2020 wbrinksma
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "subject.h"
#include <math.h>
namespace corsim
{
Subject::Subject(int x, int y, int radius, bool infected)
{
this->_x = x;
this->_y = y;
this->_radius = radius;
this->_infected = infected;
}
double Subject::x()
{
return this->_x;
}
double Subject::y()
{
return this->_y;
}
void Subject::set_x(double x)
{
this->_x = x;
}
void Subject::set_y(double y)
{
this->_y = y;
}
double Subject::dx()
{
return this->_dx;
}
double Subject::dy()
{
return this->_dy;
}
void Subject::set_dx(double dx)
{
this->_dx = dx;
}
void Subject::set_dy(double dy)
{
this->_dy = dy;
}
int Subject::radius()
{
return this->_radius;
}
bool Subject::infected()
{
return this->_infected;
}
void Subject::infect()
{
this->_infected = true;
}
double Subject::angle()
{
return atan2(_dy,_dx);
}
double Subject::speed()
{
return sqrt(_dx * _dx + _dy * _dy);
}
}