From dc104e37842049e040f7e39f4e1aab56cde1488c Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Wed, 1 Jun 2011 19:02:52 +0200 Subject: Moved common files here. --- vector.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 vector.h (limited to 'vector.h') diff --git a/vector.h b/vector.h new file mode 100644 index 0000000..a2a3192 --- /dev/null +++ b/vector.h @@ -0,0 +1,50 @@ +#ifndef VECTOR_H +#define VECTOR_H + +#include + +#include + +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 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 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 -- cgit v1.2.3