diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 20:41:19 +0200 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-10-03 20:41:19 +0200 |
commit | 386d58b5862d8b76925c6523721594887606e82a (patch) | |
tree | ef073e7a843f4b75a4008d4b7383f7cdf08ceee5 /source/Vector3i.h | |
parent | Visual Studio 2010 solution and project files (diff) | |
download | cuberite-386d58b5862d8b76925c6523721594887606e82a.tar cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.gz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.bz2 cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.lz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.xz cuberite-386d58b5862d8b76925c6523721594887606e82a.tar.zst cuberite-386d58b5862d8b76925c6523721594887606e82a.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Vector3i.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/Vector3i.h b/source/Vector3i.h new file mode 100644 index 000000000..676e7ba21 --- /dev/null +++ b/source/Vector3i.h @@ -0,0 +1,37 @@ +#pragma once
+
+#include <math.h>
+
+class Vector3d;
+class Vector3i //tolua_export
+{ //tolua_export
+public: //tolua_export
+ Vector3i( const Vector3d & v ); //tolua_export
+
+ Vector3i() : x(0), y(0), z(0) {} //tolua_export
+ Vector3i(int a_x, int a_y, int a_z) : x(a_x), y(a_y), z(a_z) {} //tolua_export
+
+ inline void Set(int a_x, int a_y, int a_z) { x = a_x, y = a_y, z = a_z; } //tolua_export
+ inline float Length() const { return sqrtf( (float)( x * x + y * y + z * z) ); } //tolua_export
+ inline int SqrLength() const { return x * x + y * y + z * z; } //tolua_export
+
+ inline bool Equals( const Vector3i & v ) const { return (x == v.x && y == v.y && z == v.z ); } //tolua_export
+ inline bool Equals( const Vector3i * v ) const { return (x == v->x && y == v->y && z == v->z ); } //tolua_export
+
+ void operator += ( const Vector3i& a_V ) { x += a_V.x; y += a_V.y; z += a_V.z; }
+ void operator += ( Vector3i* a_V ) { x += a_V->x; y += a_V->y; z += a_V->z; }
+ void operator -= ( const Vector3i& a_V ) { x -= a_V.x; y -= a_V.y; z -= a_V.z; }
+ void operator -= ( Vector3i* a_V ) { x -= a_V->x; y -= a_V->y; z -= a_V->z; }
+ void operator *= ( int a_f ) { x *= a_f; y *= a_f; z *= a_f; }
+
+ friend Vector3i operator + ( const Vector3i& v1, const Vector3i& v2 ) { return Vector3i( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z ); }
+ friend Vector3i operator + ( const Vector3i& v1, Vector3i* v2 ) { return Vector3i( v1.x + v2->x, v1.y + v2->y, v1.z + v2->z ); }
+ friend Vector3i operator - ( const Vector3i& v1, const Vector3i& v2 ) { return Vector3i( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z ); }
+ friend Vector3i operator - ( const Vector3i& v1, Vector3i* v2 ) { return Vector3i( v1.x - v2->x, v1.y - v2->y, v1.z - v2->z ); }
+ friend Vector3i operator - ( const Vector3i* v1, Vector3i& v2 ) { return Vector3i( v1->x - v2.x, v1->y - v2.y, v1->z - v2.z ); }
+ friend Vector3i operator * ( const Vector3i& v, const int f ) { return Vector3i( v.x * f, v.y * f, v.z * f ); }
+ friend Vector3i operator * ( const Vector3i& v1, const Vector3i& v2 ) { return Vector3i( v1.x * v2.x, v1.y * v2.y, v1.z * v2.z ); }
+ friend Vector3i operator * ( const int f, const Vector3i& v ) { return Vector3i( v.x * f, v.y * f, v.z * f ); }
+
+ int x, y, z; //tolua_export
+}; //tolua_export
\ No newline at end of file |