#ifndef POINT_H_INCLUDED
#define POINT_H_INCLUDED 1

// Copyright (C) 2005 Zbynek Winkler, zw at robotika cz
// Licensed to the public under the terms of the GNU GPL 2

#include <math.h>
#include "cmp.h"

class point 
{
	public:
		double m_x;
		double m_y;
	public:
		point() : m_x(), m_y() {}
		point(const double & in_x, const double & in_y) : m_x(in_x), m_y(in_y) {}
		//point(const double & in_dist, const double & in_angle) : m_x(in_dist * cos(in_angle)), m_y(in_dist * sin(in_angle)) {}

		bool eq(const point & in_p, const double & in_eps = 1e-4) const 
		{
			return ::eq(m_x, in_p.m_x, in_eps) && ::eq(m_y, in_p.m_y, in_eps);
		}

		point operator - () const { return point(-m_x, -m_y); }
		point operator - (const point & in) const { return point(m_x-in.m_x, m_y-in.m_y); }
		point operator + (const point & in) const { return point(m_x+in.m_x, m_y+in.m_y); }
		
		point & operator += (const point & in) { m_x += in.m_x; m_y += in.m_x; return *this; }
		point & operator -= (const point & in) { m_x -= in.m_x; m_y -= in.m_x; return *this; }

		double magnitude() const { return ::hypot(m_x, m_y); }
		double distanceTo(const point & in) { return (in - *this).magnitude(); }
		double angle() const { return ::atan2(m_x, m_y); }
};

#endif


