diff options
author | chirs241097@gmail.com <chirs241097@gmail.com@c17bf020-1265-9734-9302-a83f62007ddb> | 2014-03-11 09:44:43 +0000 |
---|---|---|
committer | chirs241097@gmail.com <chirs241097@gmail.com@c17bf020-1265-9734-9302-a83f62007ddb> | 2014-03-11 09:44:43 +0000 |
commit | f4832349efdf06d8a1a410c636045f505efb52f1 (patch) | |
tree | f2958f0e6194a46aa890cfe03a09c737a8afdc20 /libcgh.h | |
parent | 285f4f3379a68db34eec86cdc5c8d6f3c5597f5e (diff) | |
download | bullet-lab-remix-f4832349efdf06d8a1a410c636045f505efb52f1.tar.xz |
Complete and fix Supernova, add several interfaces.
Diffstat (limited to 'libcgh.h')
-rw-r--r-- | libcgh.h | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1,7 +1,7 @@ //Chrisoft Bullet Lab Remix HGE //Chrisoft Game Helper header //Copyright Chrisoft 2014 -//libcgh version 0006 +//libcgh version 0007 //Last full compatible version 0002 //^Modify that when big change is made^ #include <hge.h> @@ -20,13 +20,10 @@ struct vector2d double x,y; vector2d(double _x,double _y){x=_x;y=_y;} vector2d(){x=y=0;} - void ToUnitCircle() - { - double l=sqrt(sqr(x)+sqr(y)); - x/=l;y/=l; - } + double l(){return sqrt(sqr(x)+sqr(y));} + void ToUnitCircle(){double len=l();x/=len;y/=len;} void Swap(){double t=x;x=y;y=t;} - void rotate(double rad){double tx=x*cos(rad)+y*sin(rad),ty=y*cos(rad)-x*sin(rad);x=tx,y=ty;} + void Rotate(double rad){double tx=x*cos(rad)+y*sin(rad),ty=y*cos(rad)-x*sin(rad);x=tx,y=ty;} friend vector2d operator -(vector2d a,vector2d b) { return vector2d(a.x-b.x,a.y-b.y); @@ -47,6 +44,10 @@ struct vector2d { return vector2d(b.x*a,b.y*a); } + friend double operator ^(vector2d a,vector2d b)//cosine of angle + { + return (a|b)/a.l()/b.l(); + } }; inline vector2d ToUnitCircle(vector2d input) { |