-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector2d.h
37 lines (27 loc) · 948 Bytes
/
vector2d.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
#ifndef VECTOR2D_H
#define VECTOR2D_H
struct Vector2D
{
explicit Vector2D(double _x = 0.0, double _y = 0.0);
virtual ~Vector2D();
Vector2D &operator +=(const Vector2D &rhs);
Vector2D &operator -=(const Vector2D &rhs);
Vector2D &operator *=(double a);
Vector2D &operator /=(double a);
double operator ()(const Vector2D &rhs);
// make this vector normal
Vector2D &normalize(void);
// build a normal copy of *this
Vector2D normal(void);
double x;
double y;
// static Vector2D unit(double phi); -- do we need it?
};
Vector2D operator +(const Vector2D <, const Vector2D &rt);
Vector2D operator -(const Vector2D <, const Vector2D &rt);
Vector2D operator *(const Vector2D <, double a);
Vector2D operator *(double a, const Vector2D &rt);
Vector2D operator /(const Vector2D <, double a);
bool operator==(const Vector2D <, const Vector2D &rt);
bool operator!=(const Vector2D <, const Vector2D &rt);
#endif // VECTOR2D_H