-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabstractMap.cpp
59 lines (48 loc) · 1.31 KB
/
abstractMap.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
#include "abstractMap.h"
AbstractMap::AbstractMap() : points()
{
}
/**
* @brief Map::getPoints returns the collection of points in the map.
* @return A constant vector of points.
*/
const QVector<Point> &AbstractMap::getPoints() const{
return points;
}
/**
* @brief AbstractMap::getXaxis gets the X-axis as Qvector
* @return
*/
QVector<double> AbstractMap::getXaxis() const{
return this->axisExtractor(true);
}
/**
* @brief AbstractMap::getYaxis gets the Y-axis as Qvector
* @return
*/
QVector<double> AbstractMap::getYaxis() const{
return this->axisExtractor(false);
}
/**
* @brief AbstractMap::axisExtractor is a helper method that extracts a QVector representation of the points.
* @param axis determins which axis will be extracted. True for X, false for Y.
* @return
*/
QVector<double> AbstractMap::axisExtractor(bool axis) const{
QVector<double> vector;
for(Point p : points){
double coordinate = axis ? p.getX() : p.getY();
vector.append(coordinate);
}
return vector;
}
/**
* @brief Cities::Initialize creates a random map of points. Also clears any pre-existing points.
* @param number of points to be created.
*/
void AbstractMap::InitializeRandom(int number){
points.clear();
for(int i=0; i<number; i++){
points.push_back(Point());
}
}