/
Point.h
56 lines (51 loc) · 1.16 KB
/
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
50
51
52
53
54
55
56
//
// Created by Esteno on 13.04.2016.
//
#ifndef LINES_POINT_H
#define LINES_POINT_H
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
class Point;
Point operator*(double k, Point x);
class Point {
public:
double x,y;
Point() {}
Point(double _x, double _y): x(_x), y(_y) {}
Point operator+ (Point a){
return Point(x + a.x, y + a.y);
}
Point operator- (Point a){
return Point(x - a.x, y - a.y);
}
double norm() {
return sqrt(x * x + y * y);
}
double operator* (Point a){
return x * a.x + y * a.y;
}
Point operator/ (double a){
return 1. / a * Point(x, y);
}
Point e(){
return operator/(norm());
}
Point projection(Point a){
return operator*(a.e()) * a.e();
}
Point perpendicular_left(){
return Point(-y, x);
}
Point perpendicular_right(){
return Point(y, -x);
}
};
inline Point operator*(double k, Point a){
return Point(k * a.x, k * a.y);
}
bool operator== (const Point& a, const Point& b);
bool operator==(vector<Point> ans, vector<Point> res);
#endif //LINES_POINT_H