- Main Page
- Classes
- Files

- File List
- File Members

# C:/Users/Public/AGS Final Folder/BFLETCHER D4010283/Source/Game/Source/Vector2.h

Go to the documentation of this file.

    00001 //Vector2.h
    00002 #ifndef _VECTOR2_H_
    00003 #define _VECTOR2_H_
    00004
    00005 #define PI 3.141592654f
    00006 #define DEGTORAD(degree) ((PI / 180.0f) * (degree))
    00007 #define RADTODEG(radian) ((180.0f / PI) * (radian))
    00008
    00009 class Vector2
    00010 {
    00011         public:
    00012         Vector2() : x(0.0f), y(0.0f) {}
    00013         Vector2(const float &x, const float &y) : x(x), y(y) {}
    00014         Vector2(const Vector2 &vector) : x(vector.x), y(vector.y) {}
    00015         ~Vector2() {}
    00016
    00017         void set(float xx, float yy) { x = xx; y = yy; }
    00018
    00019         operator const float*() const;
    00020         Vector2  operator+  (const Vector2 &vector) const;
    00021         Vector2& operator+= (const Vector2 &vector);
    00022         Vector2  operator-  (const Vector2 &vector) const;
    00023         Vector2& operator-= (const Vector2 &vector);
    00024         Vector2  operator*  (const Vector2 &vector) const;
    00025         Vector2  operator*  (const float &f) const;
    00026         Vector2& operator*= (const float &f);
    00027         Vector2  operator/  (const float &f) const;
    00028         Vector2& operator/= (const float &f);
    00029         Vector2& operator=  (const Vector2 &vector);
    00030         bool     operator== (const Vector2 &vector) const; //Not to be used unless in some bizarre circumstance where
    00031                                                                                                                                 //floats aren't terribly slow at comparisons.
    00032         void normalise();
    00033         Vector2 perpendicular();
    00034         float getLength() const;
    00035         float getLengthSqrd() const;
    00036
    00037         static float dot(const Vector2 &left, const Vector2 &right);
    00038         static float cross(const Vector2 &left, const Vector2 &right);
    00039         static Vector2 vmin(const Vector2 &a, const Vector2 &b);
    00040         static Vector2 vmax(const Vector2 &a, const Vector2 &b);
    00041         static bool isRoughlyEqual(const Vector2 &a, const Vector2 &b);
    00042
    00043         float x, y;
    00044 };
    00045
    00046 class Vector2i
    00047 {
    00048         public:
    00049         Vector2i() : x(0), y(0) {}
    00050         Vector2i(const int &x, const int &y) : x(x), y(y) {}
    00051         Vector2i(const Vector2i &vector) : x(vector.x), y(vector.y) {}
    00052         ~Vector2i() {}
    00053
    00054         void set(int xx, int yy) { x = xx; y = yy; }
    00055
    00056         operator const int*() const;
    00057         Vector2i  operator+  (const Vector2i &vector) const;
    00058         Vector2i& operator+= (const Vector2i &vector);
    00059         Vector2i  operator-  (const Vector2i &vector) const;
    00060         Vector2i& operator-= (const Vector2i &vector);
    00061         Vector2i  operator*  (const Vector2i &vector) const;
    00062         Vector2i  operator*  (const int &n) const;
    00063         Vector2i& operator*= (const int &n);
    00064         Vector2i  operator/  (const int &n) const;
    00065         Vector2i& operator/= (const int &n);
    00066         Vector2i& operator=  (const Vector2i &vector);
    00067         bool     operator== (const Vector2i &vector) const;
    00068
    00069         float getLength() const;
    00070         int getLengthSqrd() const;
    00071         Vector2i perpendicular();
    00072
    00073         static int dot(const Vector2i &left, const Vector2i &right);
    00074         static int cross(const Vector2i &left, const Vector2i &right);
    00075         static Vector2i vmin(const Vector2i &a, const Vector2i &b);
    00076         static Vector2i vmax(const Vector2i &a, const Vector2i &b);
    00077
    00078         int x, y;
    00079 };
    00080
    00081
    00082 #endif