-
Notifications
You must be signed in to change notification settings - Fork 1
/
vector.h
41 lines (32 loc) · 1.2 KB
/
vector.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
#ifndef VECTOR_H_
#define VECTOR_H_
#include <ostream>
namespace pathfinder {
class Vector {
private:
double x_{0.0}, y_{0.0};
public:
Vector() = default;
Vector(const double x, const double y);
bool operator==(const Vector &other) const;
bool operator!=(const Vector &other) const;
void setX(const double x);
void setY(const double y);
double x() const;
double y() const;
friend Vector operator*(const Vector &lhs, double scalar);
friend Vector operator*(double scalar, const Vector &rhs);
friend Vector operator/(const Vector &lhs, double scalar);
friend Vector operator/(double scalar, const Vector &rhs);
friend Vector operator-(const Vector &lhs, const Vector &rhs);
friend Vector operator+(const Vector &lhs, const Vector &rhs);
};
Vector operator*(const Vector &lhs, double scalar);
Vector operator*(double scalar, const Vector &rhs);
Vector operator/(const Vector &lhs, double scalar);
Vector operator/(double scalar, const Vector &rhs);
Vector operator-(const Vector &lhs, const Vector &rhs);
Vector operator+(const Vector &lhs, const Vector &rhs);
std::ostream& operator<<(std::ostream &stream, const pathfinder::Vector &vector);
} // namespace pathfinder
#endif // VECTOR_H_