Creation of physics project
[physics.git] / src / Vector2.h
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&);
18
19     void zero();
20     void unit();
21
22     float angle() const;
23     float length() const;
24
25     Vector2 add(const Vector2&) const;
26     Vector2 subtract(const Vector2&) const;
27     Vector2 divide(float) const;
28     Vector2 multiply(float) const;
29
30     string toString() const;
31     void print() const;
32 };
33
34 /// ***** Header Methods *****
35 // definitions of the operators are external
36 // because (float, Vector2) would fail inside class
37 Vector2 operator+(const Vector2&, const Vector2&);
38 Vector2 operator-(const Vector2&, const Vector2&);
39 Vector2 operator*(float, const Vector2&);
40 Vector2 operator*(const Vector2&, float);
41 Vector2 operator/(const Vector2&, float);
42
43 void operator+=(Vector2&, const Vector2&);
44 void operator-=(Vector2&, const Vector2&);
45 void operator*=(Vector2&, float);
46 void operator/=(Vector2&, float);
47
48 #endif // VECTOR2_H