diff options
author | Chris Xiong <chirs241097@gmail.com> | 2015-11-01 23:32:22 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2015-11-01 23:32:22 +0800 |
commit | f68cc9034a576b6f91cf0db0344ece971944c973 (patch) | |
tree | 123744e85445f51d058b74d9c9fb2174f6abefd7 /archive/include/hgevector.h | |
parent | 1981e9bc81e92f479c725e6ac60ff3bd419cefd0 (diff) | |
download | bullet-lab-remix-f68cc9034a576b6f91cf0db0344ece971944c973.tar.xz |
Move hge to an archive.
Finish the main part of smPath.
This is a C++ project, add C++ tags to all source code that
could be identified as C source files.
Diffstat (limited to 'archive/include/hgevector.h')
-rw-r--r-- | archive/include/hgevector.h | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/archive/include/hgevector.h b/archive/include/hgevector.h deleted file mode 100644 index b86bd01..0000000 --- a/archive/include/hgevector.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -** Haaf's Game Engine 1.7 -** Copyright (C) 2003-2007, Relish Games -** hge.relishgames.com -** -** hgeVector helper class -*/ - - -#ifndef HGEVECTOR_H -#define HGEVECTOR_H - -#include <math.h> - -/* -** Fast 1.0/sqrtf(float) routine -*/ -float InvSqrt(float x); - -class hgeVector -{ -public: - float x,y; - - hgeVector(float _x, float _y) { x=_x; y=_y; } - hgeVector() { x=0; y=0; } - - hgeVector operator- () const { return hgeVector(-x, -y); } - hgeVector operator- (const hgeVector &v) const { return hgeVector(x-v.x, y-v.y); } - hgeVector operator+ (const hgeVector &v) const { return hgeVector(x+v.x, y+v.y); } - hgeVector& operator-= (const hgeVector &v) { x-=v.x; y-=v.y; return *this; } - hgeVector& operator+= (const hgeVector &v) { x+=v.x; y+=v.y; return *this; } - bool operator== (const hgeVector &v) const { return (x==v.x && y==v.y); } - bool operator!= (const hgeVector &v) const { return (x!=v.x || y!=v.y); } - - hgeVector operator/ (const float scalar) const { return hgeVector(x/scalar, y/scalar); } - hgeVector operator* (const float scalar) const { return hgeVector(x*scalar, y*scalar); } - hgeVector& operator*= (const float scalar) { x*=scalar; y*=scalar; return *this; } - - float Dot(const hgeVector *v) const { return x*v->x + y*v->y; } - float Length() const { return sqrtf(Dot(this)); } - float Angle(const hgeVector *v = 0) const; - - void Clamp(const float max) { if(Length() > max) { Normalize(); x *= max; y *= max; } } - hgeVector* Normalize() { float rc=InvSqrt(Dot(this)); x*=rc; y*=rc; return this; } - hgeVector* Rotate(float a); -}; - -inline hgeVector operator* (const float s, const hgeVector &v) { return v*s; } -inline float operator^ (const hgeVector &v, const hgeVector &u) { return v.Angle(&u); } -inline float operator% (const hgeVector &v, const hgeVector &u) { return v.Dot(&u); } - - -#endif |