forked from PhaseCycle/Biosystem-Simulation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMacroOrganism.cpp
56 lines (50 loc) · 1.24 KB
/
MacroOrganism.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
/*
Authors: Andrew Yoder, Thomas Stryjski, Zachary O'Brien
Date: 12/1/18
Class: EEEE-346-01
Assignment: Project 3
Purpose: derived class for organisms in micro-enviornments
*/
#include "MacroOrganism.h"
#include <cmath>
//getter
Point MacroOrganism::getLocation()
{
return l;
}
double MacroOrganism::get_temp() {
return temperature;
}
//setters
void MacroOrganism::setLocation(double x_new, double y_new) {
l.setCoordinates(x_new, y_new);
}
void MacroOrganism::setLocation(Point p) {
l.setCoordinates(p.getX(), p.getY());
}
void MacroOrganism::set_temp(double t){
temperature = t;
}
//operator overloads
//(subtract)
double MacroOrganism::operator-(MacroOrganism & O){
double x, y, result;
x = delta_x(O);
y = delta_y(O);
result = sqrt( pow(x,2.0) + pow(y,2.0));
return result;
}
double MacroOrganism::delta_x(MacroOrganism &O) {
return O.getLocation().getX() - l.getX();
}
double MacroOrganism::delta_y(MacroOrganism &O) {
return O.getLocation().getY() - l.getY();
}
double MacroOrganism::unit_x(MacroOrganism &O) {
return delta_x(O) / (*this - O);
}
double MacroOrganism::unit_y(MacroOrganism &O) {
return delta_y(O) / (*this - O);
}
//