Commit | Line | Data |
---|---|---|
ad9f1fb6 PG |
1 | #ifndef VECTOR2_H |
2 | #define VECTOR2_H | |
3 | ||
4 | #include <string> | |
5 | ||
6 | using std::string; | |
7 | ||
8 | /// ***** Header Class ***** | |
9 | class Vector2 | |
10 | { | |
11 | public: | |
12 | float x; | |
13 | float y; | |
14 | ||
15 | Vector2(); | |
16 | Vector2(float, float); | |
17 | Vector2(const Vector2&); | |
617dcc71 | 18 | ~Vector2(); |
ad9f1fb6 PG |
19 | |
20 | void zero(); | |
21 | void unit(); | |
22 | ||
23 | float angle() const; | |
24 | float length() const; | |
25 | ||
26 | Vector2 add(const Vector2&) const; | |
27 | Vector2 subtract(const Vector2&) const; | |
28 | Vector2 divide(float) const; | |
29 | Vector2 multiply(float) const; | |
30 | ||
31 | string toString() const; | |
32 | void print() const; | |
33 | }; | |
34 | ||
35 | /// ***** Header Methods ***** | |
617dcc71 PG |
36 | |
37 | // definitions of the operators are external because (float, Vector2) would | |
38 | // fail inside the class | |
39 | ||
ad9f1fb6 PG |
40 | Vector2 operator+(const Vector2&, const Vector2&); |
41 | Vector2 operator-(const Vector2&, const Vector2&); | |
42 | Vector2 operator*(float, const Vector2&); | |
43 | Vector2 operator*(const Vector2&, float); | |
44 | Vector2 operator/(const Vector2&, float); | |
45 | ||
46 | void operator+=(Vector2&, const Vector2&); | |
47 | void operator-=(Vector2&, const Vector2&); | |
48 | void operator*=(Vector2&, float); | |
49 | void operator/=(Vector2&, float); | |
50 | ||
51 | #endif // VECTOR2_H |