EMD/Euclidean.hpp

94 lines
2.0 KiB
C++
Raw Normal View History

2011-12-06 00:17:32 +08:00
#ifndef __EUCLIDIAN_HPP__
#define __EUCLIDIAN_HPP__
#include <math.h>
2012-01-10 05:09:51 +08:00
#include <vector>
2011-12-06 00:17:32 +08:00
2012-01-11 01:43:31 +08:00
/**
* Euclidean class.
*
* @author William Durand <william.durand1@gmail.com>
* @author Guillaume Bernard <guill.bernard1@gmail.com>
*/
2011-12-06 00:17:32 +08:00
class Euclidean
{
public:
2012-01-11 01:43:31 +08:00
/**
* Constructor
*
* @param const int x Coordinate X
* @param const int y Coordinate Y
*/
2011-12-06 00:17:32 +08:00
Euclidean(const int x, const int y) : _x(x), _y(y) {}
2012-01-11 01:43:31 +08:00
/**
* @param const int x Coordinate X
*/
2011-12-06 00:17:32 +08:00
void setX(const int x) { _x = x; }
2012-01-11 01:43:31 +08:00
/**
* @return const int
*/
2011-12-06 00:17:32 +08:00
int getX() const { return _x; }
2012-01-11 01:43:31 +08:00
/**
* @param const int y Coordinate Y
*/
2011-12-06 00:17:32 +08:00
void setY(const int y) { _y = y; }
2012-01-11 01:43:31 +08:00
/**
* @return const int
*/
2011-12-06 00:17:32 +08:00
int getY() const { return _y; }
2012-01-11 01:43:31 +08:00
/**
* @param const double distance A distance.
*/
2011-12-06 00:17:32 +08:00
void setDistance(const double distance) { _distance = distance; }
2012-01-11 01:43:31 +08:00
/**
* @return const double
*/
2011-12-06 00:17:32 +08:00
double getDistance() const { return _distance; }
2012-01-11 01:43:31 +08:00
/**
* @param Euclidean & nearest
*/
2011-12-06 00:17:32 +08:00
void setNearest(Euclidean & nearest) { _nearest = &nearest; }
2012-01-11 01:43:31 +08:00
/**
* @return const Euclidean*
*/
2011-12-06 00:17:32 +08:00
Euclidean* getNearest() const { return _nearest; }
2012-01-11 01:43:31 +08:00
/**
* @param const Euclidean & euclidean
* @return const double
*/
double computeDistanceFrom(const Euclidean & euclidean) const;
2011-12-06 00:17:32 +08:00
2012-01-11 01:43:31 +08:00
/**
* @param const std::vector<Euclidean>
* @return double
*/
static double max(const std::vector<Euclidean> vect);
2012-01-11 01:43:31 +08:00
/**
* @param const std::vector<Euclidean>
* @return double
*/
static double min(const std::vector<Euclidean> vect);
2011-12-06 00:17:32 +08:00
private:
2011-12-06 00:17:32 +08:00
int _x;
int _y;
double _distance;
Euclidean *_nearest;
};
#endif