-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdistance.cpp
More file actions
44 lines (38 loc) · 906 Bytes
/
distance.cpp
File metadata and controls
44 lines (38 loc) · 906 Bytes
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
#include "distance.hpp"
#include "rsdl.hpp"
Distance::Distance(Point _curr, Point _prev){
curr = _curr;
prev = _prev;
}
double Distance::getXDistance(){
float prevX = prev.x;
float currX = curr.x;
return currX - prevX;
}
double Distance::getYDistance(){
float prevY = prev.y;
float currY = curr.y;
return currY - prevY;
}
double Distance::getDistance(){
double distance = sqrt(pow(getXDistance(),2) + pow(getYDistance(),2));
return distance;
}
bool Distance::isXExeeds(){
if(getXDistance() > maxTensionRadius || getXDistance() < -maxTensionRadius){
return true;
}
return false;
}
bool Distance::isYExeeds(){
if(getYDistance() > maxTensionRadius || getYDistance() < -maxTensionRadius){
return true;
}
return false;
}
int Distance::isPositive(double k){
if(k >= 0){
return 1;
}
return -1;
}