summaryrefslogtreecommitdiff
path: root/vector.h
blob: 48deb871642964ec52e3aacd5bf60ca88e767895 (plain)
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 VECTOR_H
#define VECTOR_H

#include <boost/shared_ptr.hpp>

#include <string>

class Vector2 {
	public:
		float x, y;

		Vector2();
		Vector2(const Vector2& v);
		Vector2(float x, float y);
		bool operator==(const Vector2& v) const;
		Vector2& operator+=(const Vector2& v);
		Vector2& operator-=(const Vector2& v);
		Vector2 operator-(const Vector2& v);
		Vector2& operator*=(const float f);
		Vector2& operator/=(const float f);
		float length();
		std::string str();
};

class Vector3 : public Vector2 {
	public:
		typedef boost::shared_ptr<Vector3> p;
		float z;

		Vector3();
		Vector3(const Vector3& v);
		Vector3(float x, float y, float z);
		bool operator==(const Vector3& v);
		Vector3& operator+=(const Vector3& v);
		Vector3 operator+(const Vector3& v);
		Vector3& operator-=(const Vector3& v);
		Vector3 operator-(const Vector3& v);
		Vector3& operator*=(const float f);
		Vector3 operator*(const float f);
		Vector3& operator/=(const float f);
		Vector3 operator/(const float f);
		Vector3 cross(const Vector3& v);
		float dot(const Vector3& v);
		Vector2 xz();
		float length();
		std::string str();
};

#endif