summaryrefslogtreecommitdiffstats
path: root/kue/point.h
blob: c748e7d32ca06b3947c254b5a3f5589b01d63df5 (plain)
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
#ifndef _POINT_H
#define _POINT_H

#include <math.h>

// Point is just a point on a 2D plane
class point {
  public:
	point(double x = 0.0, double y = 0.0);
	~point();

	// Gets our position
	double positionX() const { return _pos_x; }
	double positionY() const { return _pos_y; }

	// Sets our position
	void setPositionX(double new_pos) {_pos_x = new_pos;}
	void setPositionY(double new_pos) {_pos_y = new_pos;}
	void setPosition(double new_x, double new_y) {_pos_x = new_x; _pos_y = new_y; }
	void setPosition(const point &p) {_pos_x = p._pos_x; _pos_y = p._pos_y; }

	// Finds the distance between us and another point
	double distance(const point &other_point) const;
	// Finds the angle between us and another point
	double angle(const point &other_point) const { return atan2(other_point._pos_y - _pos_y, other_point._pos_x - _pos_x); }

  protected:
	double _pos_x;
	double _pos_y;
};

#endif