-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.h
More file actions
49 lines (38 loc) · 1 KB
/
Copy pathPoint.h
File metadata and controls
49 lines (38 loc) · 1 KB
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
#define POINT_H
#include <math.h>
class Point {
public:
double x_, y_;
Point() {};
Point(double x, double y) : x_(x), y_(y) {};
double operator*(const Point& o) {
double a = sqrt((x_ - o.x_)*(x_ - o.x_)+(y_ - o.y_)*(y_ - o.y_));
return a;
}
Point operator*(const int& a){
return Point(x_*a,y_*a);
}
Point operator-(const Point& o) {
return Point(x_ - o.x_ , y_ - o.y_);
}
Point operator+(const Point& o){
return Point(x_+o.x_,y_+o.y_);
}
Point operator/(const int& a){
return Point(x_/a,y_/a);
}
double operator>>(const Point& o) {
double ip = x_*o.x_ + y_*o.y_;
return ip;
}
double Length() {
double l = sqrt(x_*x_+y_*y_);
return l;
}
void Normalize() {
x_ = x_/Length();
y_ = y_/Length();
}
};
#endif