-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoint.h
49 lines (37 loc) · 1022 Bytes
/
point.h
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
#ifndef POINT_H_INCLUDED
#define POINT_H_INCLUDED
#pragma warning(disable : 4786)
#include <functional>
#include <iostream>
#include <cmath>
namespace Animator
{
class Point
{
public:
Point(void);
Point(const float& x, const float& y);
void toStream(std::ostream& output_stream) const;
void fromStream(std::istream& input_stream);
float distance(const Point& p) const {
float xd = x - p.x;
float yd = y - p.y;
return sqrtf(xd * xd + yd * yd);
}
float x;
float y;
};
std::ostream& operator<<(std::ostream& output_stream, const Animator::Point& point);
std::istream& operator>>(std::istream& input_stream, Animator::Point& point);
class PointSmallerXCompare : public std::binary_function<const Point&, const Point&, bool>
{
public:
bool operator()(const Point& first, const Point& second) const;
};
class PointLargerXCompare : public std::binary_function<const Point&, const Point&, bool>
{
public:
bool operator()(const Point& first, const Point& second) const;
};
};
#endif // POINT_H_INCLUDED