Homework
This week your task will be to modify the code from monday's session to work on n-dimensional data points.
Clusterer-2D
Feel free to fork the repl.it and include a new class "PointND".
The Class PointND should should be structured as shown in the following header file:
#ifndef PointN_H
#define PointN_H
#include <vector>
using namespace std;
class PointND {
public:
PointND(int dimensions); // constructor for zero point of n-dimensions
PointND(vector<float> newND); // constructor for a point which copies the coordinates from an n-dimensional vector
PointND operator+(PointND& p2);
PointND operator/(float f);
float getDim(int idx_dimension); // get the component of the indexed dimension, (this was getX() and getY() before)
int size() // return how many dimension our current point has!
{
return _pointND.size();
}
void print();
float getDistance(PointND&); // extend the euclidean distance to n dimensions
private:
vector<float> _pointND;
};
#endif
Implement a PointND.cpp file that behaves like our class Point2D on n-dimensional points Test that class with a 3D distance measurement, and on success Modify our clusterer to work with the new PointND class!
Have fun and if you're stuck, write a mail or post a message in the forum!
Best wishes, Clemens