Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
//vector.h #include"stdafx.h" #include<math.h> #include<string> ///////////// ~!DAS!~ ////////////// //////////////// ~!BITWISE!~ //////////////// /////////// ~!MEISTER!~ ///////////// namespace Vector { class V2 { public: float x, y; V2() : x(0), y(0) {} V2(V2&vec) : x(vec.x), y(vec.y) {} V2(float xx, float yy) : x(xx), y(yy) {} V2(int addr) : x(*(float*)(addr)), y(*(float*)(addr+4)) {} void memset(int addr); void debugVector(); V2 & operator++(); V2 & operator--(); bool operator==(V2&vec); bool operator!=(V2&vec); bool operator>(V2&vec); bool operator<(V2&vec); bool operator!(); V2 & operator=(V2&vec); V2 & operator=(float value); V2 & operator+(V2&vec); V2 & operator+(float value); V2 & operator-(V2&vec); V2 & operator-(float value); V2 & operator/(V2&vec); V2 & operator/(float vec); V2 & operator+=(V2&vec); V2 & operator+=(float value); V2 & operator-=(V2&vec); V2 & operator-=(float value); V2 & operator/=(V2&vec); V2 & operator/=(float value); V2 & operator<<(unsigned int bit); V2 & operator<<=(unsigned int bit); V2 & operator>>(unsigned int bit); V2 & operator>>=(unsigned int bit); V2 & operator|(V2&vec); V2 & operator|(float value); V2 & operator|=(V2&vec); V2 & operator|=(float value); V2&operator^(V2&vec); V2&operator^(float value); V2&operator^=(V2&vec); V2&operator^=(float value); V2&operator&(V2&vec); V2&operator&(float value); V2&operator&=(V2&vec); V2&operator&=(float value); V2&operator~(); V2&operator*(V2&vec); V2&operator*(float value); V2&operator*=(V2&vec); V2&operator*=(float value); V2&operator%(V2&vec); V2&operator%(float value); V2&operator%=(V2&vec); V2&operator%=(float value); float Length(); float LengthSquared(); float Distance(V2&vec); float DistanceSquared(V2&vec); float Dot(V2&vec); float V2Normalize(); V2&Sin(), &Cos(), &Tan(), &ASin(), &ACos(), &ATan(); V2&Sin2(), &Cos2(), &Tan2(), &ASin2(), &ACos2(), &ATan2(); V2&Floor(), &Ceil(), &Sqrt(); V2&Max(V2&vec); V2&vrand(V2&max); V2&Normalize(); bool Closer(V2&line1, V2&line2); }; class V3 { public: float x, y, z; V3() : x(0), y(0), z(0) {} V3(V3&vec) : x(vec.x), y(vec.y), z(vec.z) {} V3(float xx, float yy, float zz) : x(xx), y(yy), z(zz) {} V3(int addr) : x(*(float*)(addr)), y(*(float*)(addr+4)), z(*(float*)(addr+8)) {} void memset(int addr); void debugVec(); V3&operator()(float xx, float yy, float zz); V3&operator++(); V3&operator--(); bool operator==(V3&vec); bool operator!=(V3&vec); bool operator>(V3&vec); bool operator<(V3&vec); bool operator!(); V3&operator=(V3&vec); V3&operator=(float value); V3&operator+(V3&vec); V3&operator+(float value); V3&operator-(V3&vec); V3&operator-(float value); V3&operator/(V3&vec); V3&operator/(float vec); V3&operator+=(V3&vec); V3&operator+=(float value); V3&operator-=(V3&vec); V3&operator-=(float value); V3&operator/=(V3&vec); V3&operator/=(float value); V3&operator<<(unsigned int bit); V3&operator<<=(unsigned int bit); V3&operator>>(unsigned int bit); V3&operator>>=(unsigned int bit); V3&operator|(V3&vec); V3&operator|(float value); V3&operator|=(V3&vec); V3&operator|=(float value); V3&operator^(V3&vec); V3&operator^(float value); V3&operator^=(V3&vec); V3&operator^=(float value); V3&operator&(V3&vec); V3&operator&(float value); V3&operator&=(V3&vec); V3&operator&=(float value); V3&operator~(); V3&operator*(V3&vec); V3&operator*(float value); V3&operator*=(V3&vec); V3&operator*=(float value); V3&operator%(V3&vec); V3&operator%(float value); V3&operator%=(V3&vec); V3&operator%=(float value); float Length(); float LengthSquared(); float Distance(V3&vec); float DistanceSquared(V3&vec); float Dot(V3&vec); float V3Normalize(); V3&Sin(), &Cos(), &Tan(), &ASin(), &ACos(), &ATan(); V3&Sin2(), &Cos2(), &Tan2(), &ASin2(), &ACos2(), &ATan2(); V3&Floor(), &Ceil(), &Sqrt(); V3&Max(V3&vec); V3&vrand(V3&max); V3&Normalize(); V3&Lerp(V3&vec, float lerp); bool Closer(V3&line1, V3&line2); }; class V4 { public: float x, y, z, w; V4() : x(0), y(0), z(0), w(0) {} V4(float xx, float yy, float zz, float ww) : x(xx), y(yy), z(zz), w(ww) {} V4(V4&vec) : x(vec.x), y(vec.y), z(vec.z), w(vec.w) {} V4(int addr) : x(*(float*)(addr)), y(*(float*)((addr)+4)), z(*(float*)((addr)+8)), w(*(float*)((addr)+0xC)) {} void memset(int addr); void debugVec(); V4&operator()(float xx, float yy, float zz, float ww); V4&operator++(); V4&operator--(); bool operator==(V4&vec); bool operator!=(V4&vec); bool operator>(V4&vec); bool operator<(V4&vec); bool operator!(); V4&operator=(V3&vec); V4&operator=(float value); V4&operator+(V4&vec); V4&operator+(float value); V4&operator-(V4&vec); V4&operator-(float value); V4&operator/(V4&vec); V4&operator/(float vec); V4&operator+=(V4&vec); V4&operator+=(float value); V4&operator-=(V4&vec); V4&operator-=(float value); V4&operator/=(V4&vec); V4&operator/=(float value); V4&operator<<(unsigned int bit); V4&operator<<=(unsigned int bit); V4&operator>>(unsigned int bit); V4&operator>>=(unsigned int bit); V4&operator|(V4&vec); V4&operator|(float value); V4&operator|=(V4&vec); V4&operator|=(float value); V4&operator^(V4&vec); V4&operator^(float value); V4&operator^=(V4&vec); V4&operator^=(float value); V4&operator&(V4&vec); V4&operator&(float value); V4&operator&=(V4&vec); V4&operator&=(float value); V4&operator~(); V4&operator*(V4&vec); V4&operator*(float value); V4&operator*=(V4&vec); V4&operator*=(float value); V4&operator%(V4&vec); V4&operator%(float value); V4&operator%=(V4&vec); V4&operator%=(float value); V4&QuatLerp(V4&qb, float frac); }; } typedef Vector::V2 vec2; typedef Vector::V3 vec3; typedef Vector::V4 vec4; //vector.cpp #include"stdafx.h" #include "vector.h" #include<random> #include<time.h> #pragma region Vector2 void vec2::memset(int addr) { *(float*)(addr) = x, *(float*)(addr+4) = y; } vec2& vec2::operator++() { x++, y++; return V2(x, y); } vec2& vec2::operator--() { x--, y--; return V2(x, y); } bool vec2::operator==(V2&vec) { return (x==vec.x&&y==vec.y); } bool vec2::operator!=(V2&vec) { return (x!=vec.x&&y!=vec.y); } bool vec2::operator<(V2&vec) { return (x<vec.x&&y<vec.y); } bool vec2::operator>(V2&vec) { return (x>vec.x&&y>vec.y); } vec2& vec2::operator=(V2&vec) { return V2((x=vec.x), (y=vec.y)); } vec2& vec2::operator=(float value) { return V2((x=value), (y=value)); } vec2& vec2::operator-(V2&vec) { return V2(x-vec.x, y-vec.y); } vec2& vec2::operator<<(unsigned int bit) { int xx = 0, yy = 0; while(bit <= 31){ xx = int(int(x)<< bit), yy = int(int(y) << bit); break; } return V2(float(xx), float(yy)); } vec2& vec2::operator<<=(unsigned int bit) { int xx = 0, yy = 0; while(bit <= 31){ xx = int(int(x) << bit), yy = int(int(y) << bit); } return V2(x = float(xx), y = float(yy)); } vec2& vec2::operator>>(unsigned int bit) { int xx=0,yy=0; while(bit <= 31){ xx = int(int(x) >> bit), yy = int(int(y) >> bit); break; } return V2(float(xx), float(yy)); } vec2& vec2::operator>>=(unsigned int bit) { int xx=0,yy=0; while(bit <= 31){ xx = int(int(x) >> bit), yy = int(int(y) >> bit); break; } return V2(float(xx), float(yy)); } vec2& vec2::operator|(V2&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }; return V2(float(xx[0] | xx[1]), float(yy[0]|yy[1])); } vec2& vec2::operator|(float value) { int xx[2] = { int(x), int(value) }, yy = int(y); return V2(float(xx[0]|xx[1]), float(yy|xx[1])); } vec2& vec2::operator|=(V2&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }; return V2(x = float(xx[0|xx[1]]), y = float(yy[0]|yy[1])); } vec2& vec2::operator|=(float value) { int xx[2] = { int(x), int(value) }, yy = int(y); return V2(x = float(xx[0]|xx[1]), y = float(yy|xx[1])); } vec2& vec2::operator^(V2&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }; return V2(float(xx[0]^xx[1]), float(yy[0]^yy[1])); } vec2&vec2::operator^(float value) { int xx[2] = { int(x), int(value) }, yy = int(y); return V2(float(xx[0]^xx[1]), float(yy^xx[1])); } vec2&vec2::operator^=(V2&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }; return V2(x = float(xx[0]^xx[1]), y = float(yy[0]^yy[1])); } vec2&vec2::operator^=(float value) { int xx[2] = { int(x), int(value) }, yy = int(y); return V2(x = float(xx[0]^xx[1]), y = float(yy^xx[1])); } vec2& vec2::operator&(V2&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }; return V2(float(xx[0]&xx[1]), float(yy[0]&yy[1])); } vec2&vec2::operator&(float value) { int xx[2] = { int(x), int(value) }, yy = int(y); return V2(float(xx[0]&xx[1]), float(yy&xx[1])); } vec2& vec2::operator&=(V2&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }; return V2(x = float(xx[0]&xx[1]), y = float(yy[0]&yy[1])); } vec2&vec2::operator&=(float value) { int xx[2] = { int(x), int(value) }, yy = int(y); return V2(x = float(xx[0]&xx[1]), y = float(yy&xx[1])); } vec2& vec2::operator~() { int xy[2] = { int(x), int(y) }; return V2(float(~xy[0]), float(~xy[1])); } vec2& vec2::operator*(V2&vec) { return V2(x*vec.x,y*vec.y); } vec2& vec2::operator*(float value) { return V2(x*value, y*value); } vec2 & vec2::operator+(float value) { return V2(x+value, y+value); } vec2&vec2::operator+(V2&vec) { return V2(x+vec.x, y+vec.y); } vec2& vec2::operator-(float value) { return V2(x-value, y-value); } vec2& vec2::operator/(V2&vec) { while(vec.x && vec.y){ return V2(x/vec.x, y/vec.y);} return V2(0, 0); } vec2& vec2::operator/(float value) { while(value){ return V2(x/value, y/value);} return V2(0, 0); } vec2& vec2::operator+=(V2 & vec) { return V2(x += vec.x, y += vec.y); } vec2&vec2::operator+=(float value) { return V2(x += value, y += value); } vec2& vec2::operator-=(V2 & vec) { return V2(x -= vec.x, y -= vec.y); } vec2&vec2::operator-=(float value) { return V2(x -= value, y -= value); } vec2& vec2::operator/=(V2 & vec) { while(vec.x && vec.y){ return V2(x /= vec.x, y /= vec.y);} return V2(0, 0); } vec2&vec2::operator/=(float value) { return V2(x /= value, y /= value); } vec2&vec2::operator*=(V2&vec) { return V2(x *= vec.x, y *= vec.y); } vec2&vec2::operator*=(float value) { return V2(x *= value, y *= value); } vec2&vec2::operator%(V2&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }; xx[0] %= xx[1]; yy[0] %= yy[1]; return V2(float(xx[0]), float(yy[0])); } vec2&vec2::operator%(float value) { int xx[2] = { int(x), int(value) }, yy = int(y); xx[0] %= xx[1]; yy %= xx[1]; return V2(float(xx[0]), float(yy)); } vec2&vec2::operator%=(V2&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }; xx[0] %= xx[1]; yy[0] %= yy[1]; return V2(x = float(xx[0]), y = float(yy[0])); } vec2&vec2::operator%=(float value) { int xx[2] = { int(x), int(value) }, yy = int(y); xx[0] %= xx[1]; yy %= xx[1]; return V2(x = float(xx[0]), y = float(yy)); } float vec2::Length() { return sqrt(y*y+x*x); } float vec2::LengthSquared() { return (y*y+x*x); } float vec2::Distance(V2&vec) { return sqrt((x - vec.x)*(x - vec.x) + (x - vec.y) * (x - vec.y)); } float vec2::DistanceSquared(V2&vec) { return ((x - vec.x)*(x - vec.x) + (x - vec.y) * (x - vec.y)); } vec2& vec2::Sin() { return V2(sin(x), sin(y)); } vec2& vec2::Cos() { return V2(cos(x), cos(y)); } vec2& vec2::Tan() { return V2(tan(x), tan(y)); } vec2& vec2::ASin() { return V2(asin(x), asin(y)); } vec2& vec2::ACos() { return V2(acos(x), acos(y)); } vec2& vec2::ATan() { return V2(atan(x), atan(y)); } vec2& vec2::Sin2() { return V2(sin(x*0.017453292), sin(y*0.017453292)); } vec2& vec2::Cos2() { return V2(cos(x*0.017453292), cos(y*0.017453292)); } vec2& vec2::Tan2() { return V2(tan(x*0.017453292), tan(y*0.017453292)); } vec2& vec2::ASin2() { return V2(asin(x*0.017453292), asin(y*0.017453292)); } vec2& vec2::ACos2() { return V2(acos(x*0.017453292), acos(y*0.017453292)); } vec2&vec2::ATan2() { return V2(atan(x*0.017453292), atan(y*0.017453292)); } vec2& vec2::Floor() { return V2(floor(x), floor(y)); } vec2&vec2::Ceil() { return V2(ceil(x), ceil(y)); } vec2&vec2::Sqrt() { return V2(sqrt(x), sqrt(y)); } bool vec2::operator!() { return (!x && !y); } vec2&vec2::vrand(V2&max) { float diff = (max.x - x) + (max.y - y); srand(time(0) * (int)(time(0) % (int)diff)); return V2(rand() + int(x)+1 % int(max.x)+1, rand() + int(y)+1 % int(max.y)+1); } float vec2::Dot(V2&vec) { return ((y*vec.y) + (vec.x * x)); } float vec2::V2Normalize() { float math = 0; if(-sqrt(x*x+y*y) < 0) { math = 1.0; } else { math = sqrt(y*y+x*x); } x = x * (math / 1.0); y = y * (math / 1.0); return sqrt(x*x+y*y); } vec2& vec2::Normalize() { vec2 normal; normal.V2Normalize(); return normal; } bool vec2::Closer(V2&line1, V2&line2) { return (line1.DistanceSquared(vec2(x, y)) < line2.DistanceSquared(vec2(x, y))); } vec2& vec2::Max(V2&vec) { return V2(x, y) < vec ? vec : V2(x, y); } void vec2::debugVector() { printf("x = %f\ny = %f\n", x, y); } #pragma endregion #pragma region Vector3 void vec3::memset(int addr) { *(float*)(addr) = x, *(float*)(addr+4) = y, *(float*)(addr+8) = z; } void vec3::debugVec() { printf("x = %f\ny = %f\nz = %f\n", x, y, z); } vec3& vec3::operator++() { x++, y++, z++; return V3(x, y, z); } vec3& vec3::operator--() { x--, y--, z--; return V3(x, y, z); } bool vec3::operator==(V3&vec) { return (x==vec.x&&y==vec.y&&z==vec.z); } bool vec3::operator!=(V3&vec) { return (x!=vec.x&&y!=vec.y&&vec.z!=z); } bool vec3::operator<(V3&vec) { return (x<vec.x&&y<vec.y&&z<vec.z); } bool vec3::operator>(V3&vec) { return (x>vec.x&&y>vec.y&&z>vec.x); } vec3& vec3::operator=(V3&vec) { return vec3(x=vec.x, y=vec.y, z=vec.z); } vec3& vec3::operator=(float value) { return V3(x = value, y = value, z = value); } vec3& vec3::operator-(V3&vec) { return V3(x-vec.x, y-vec.y, z-vec.z); } vec3& vec3::operator<<(unsigned int bit) { int xx = 0, yy = 0, zz = 0; while(bit <= 31){ xx = int(int(x)<< bit), yy = int(int(y) << bit), zz = int(int(z) << bit); break; } return V3(float(xx), float(yy), float(zz)); } vec3& vec3::operator<<=(unsigned int bit) { int xx = 0, yy, zz = 0; while(bit <= 31){ xx = int(int(x) << bit), yy = int(int(y) << bit), zz = int(int(z) << bit); break;} return V3(x = float(xx), y = float(yy), z = float(zz)); } vec3& vec3::operator>>(unsigned int bit) { int xx=0,yy=0,zz=0; while(bit <= 31){ xx = int(int(x) >> bit), yy = int(int(y) >> bit), zz - int(int(z) >> bit); break;} return V3(float(xx), float(yy), float(zz)); } vec3& vec3::operator>>=(unsigned int bit) { int xx=0,yy=0,zz=0; while(bit <= 31){ xx = int(int(x) >> bit), yy = int(int(y) >> bit), zz = int(int(z) << bit); break;} return V3(x = float(xx), y = float(yy), z = float(zz)); } vec3& vec3::operator|(V3&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }, zz[2] = { int(z), int(vec.z) }; return V3(float(xx[0] | xx[1]), float(yy[0]|yy[1]), float(zz[0]|zz[1])); } vec3& vec3::operator|(float value) { int xx[2] = { int(x), int(value) }, yy = int(y), zz = int(z); return V3(float(xx[0]|xx[1]), float(yy|xx[1]), float(zz|xx[1])); } vec3& vec3::operator|=(V3&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }, zz[2] = { int(z), int(vec.z) }; return V3(x = float(xx[0|xx[1]]), y = float(yy[0]|yy[1]), float(zz[0]|zz[1]));; } vec3& vec3::operator|=(float value) { int xx[2] = { int(x), int(value) }, yy = int(y), zz = int(z); return V3(x = float(xx[0]|xx[1]), y = float(yy|xx[1]), z = float(zz|xx[1])); } vec3& vec3::operator^(V3&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }, zz[2] = { int(z), int(vec.z) }; return V3(float(xx[0]^xx[1]), float(yy[0]^yy[1]), float(zz[0]^zz[1])); } vec3&vec3::operator^(float value) { int xx[2] = { int(x), int(value) }, yy = int(y), zz = int(z); return V3(float(xx[0]^xx[1]), float(yy^xx[1]), float(zz^xx[1])); } vec3&vec3::operator^=(V3&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }, zz[2] = { int(z), int(vec.z) }; return V3(x = float(xx[0]^xx[1]), y = float(yy[0]^yy[1]), z = float(zz[0]^zz[1])); } vec3&vec3::operator^=(float value) { int xx[2] = { int(x), int(value) }, yy = int(y), zz = int(z); return V3(x = float(xx[0]^xx[1]), y = float(yy^xx[1]), z = float(zz^xx[1])); } vec3& vec3::operator&(V3&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }, zz[2] = { int(z), int(vec.z) }; return V3(float(xx[0]&xx[1]), float(yy[0]&yy[1]), float(zz[0]&zz[1])); } vec3&vec3::operator&(float value) { int xx[2] = { int(x), int(value) }, yy = int(y), zz = int(z); return V3(float(xx[0]&xx[1]), float(yy&xx[1]), float(zz&xx[1])); } vec3& vec3::operator&=(V3&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }, zz[2] = { int(z), int(vec.z) }; return V3(x = float(xx[0]&xx[1]), y = float(yy[0]&yy[1]), z = float(zz[0]&zz[1])); } vec3&vec3::operator&=(float value) { int xx[2] = { int(x), int(value) }, yy = int(y), zz = int(z); return V3(x = float(xx[0]&xx[1]), y = float(yy&xx[1]), z = float(zz&xx[1])); } vec3& vec3::operator~() { int xyz[3] = { int(x), int(y), int(z) }; return V3(float(~xyz[0]), float(~xyz[1]), float(~xyz[2])); } vec3& vec3::operator*(V3&vec) { return V3(x*vec.x,y*vec.y,z*vec.z); } vec3& vec3::operator*(float value) { return V3(x*value, y*value, z*value); } vec3 & vec3::operator+(float value) { return V3(x+value, y+value, z+value); } vec3&vec3::operator+(V3&vec) { return V3(x+vec.x, y+vec.y, z+vec.z); } vec3& vec3::operator-(float value) { return V3(x-value, y-value, z-value); } vec3& vec3::operator+=(V3 & vec) { return V3(x += vec.x, y += vec.y, z += vec.z); } vec3&vec3::operator+=(float value) { return V3(x += value, y += value, z += value); } vec3& vec3::operator-=(V3 & vec) { return V3(x -= vec.x, y -= vec.y, z -= vec.z); } vec3&vec3::operator-=(float value) { return V3(x -= value, y -= value, z -= value); } vec3& vec3::operator/=(V3 & vec) { return V3(x /= vec.x, y /= vec.y, z /= vec.z); } vec3&vec3::operator/=(float value) { return V3(x /= value, y /= value, z /= value); } vec3&vec3::operator*=(V3&vec) { return V3(x *= vec.x, y *= vec.y, z *= vec.z); } vec3&vec3::operator*=(float value) { return V3(x *= value, y *= value, z *= value); } vec3&vec3::operator%(V3&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }, zz[2] = { int(z), int(vec.z) }; return V3(float(xx[0]%xx[1]), float(yy[0]%yy[1]), float(zz[0]%zz[1])); } vec3&vec3::operator%(float value) { int xx[2] = { int(x), int(value) }, yy = int(y), zz = int(z); return V3(float(xx[0]%xx[1]), float(yy%xx[1]), float(zz%xx[1])); } vec3&vec3::operator%=(V3&vec) { int xx[2] = { int(x), int(vec.x) }, yy[2] = { int(y), int(vec.y) }, zz[2] = { int(z), int(vec.z) }; return V3(x = float(xx[0]%xx[1]), y = float(yy[0]%yy[1]), z = float(zz[0]%zz[1])); } vec3&vec3::operator%=(float value) { int xx[2] = { int(x), int(value) }, yy = int(y), zz = int(z); return V3(x = float(xx[0]%xx[1]), y = float(yy%xx[1]), z = float(zz%xx[1])); } vec3& vec3::Max(vec3&vec) { if(V3(x, y, z) < vec) { return vec; } return V3(x, y, z); } float vec3::Length() { return sqrt(z*z+y*y+x*x); } float vec3::LengthSquared() { return (z*z+y*y+x*x); } float vec3::Distance(V3&vec) { return sqrt((y-vec.y)*(y-vec.y) + (z-vec.z)*(z-vec.z) + (x-vec.x)*(x-vec.x)); } float vec3::DistanceSquared(V3&vec) { return ((y-vec.y)*(y-vec.y) + (z-vec.z)*(z-vec.z) + (x-vec.x)*(x-vec.x)); } float vec3::Dot(V3&vec) { return z*vec.z + (y*vec.y + vec.x * x); } float vec3::V3Normalize() { float math = 0; if(-sqrt(x*x+y*y+z*z) < 0) { math = 1.0; } else { math = sqrt(y*y+x*x+z*z); } x = x * (math / 1.0); y = y * (math / 1.0); z = z * (math / 1.0); return sqrt(x*x+y*y+z*z); } vec3& vec3::Normalize() { vec3 normal; normal.V3Normalize(); return normal; } vec3& vec3::Sin() { return V3(sin(x), sin(y), sin(z)); } vec3& vec3::Cos() { return V3(cos(x), cos(y), cos(z)); } vec3& vec3::Tan() { return V3(tan(x), tan(y), tan(z)); } vec3& vec3::ASin() { return V3(asin(x), asin(y), asin(z)); } vec3& vec3::ACos() { return V3(acos(x), acos(y), acos(z)); } vec3& vec3::ATan() { return V3(atan(x), atan(y), atan(z)); } vec3& vec3::Sin2() { return V3(sin(x*0.017453292), sin(y*0.017453292), sin(z*0.017453292)); } vec3& vec3::Cos2() { return V3(cos(x*0.017453292), cos(y*0.017453292), cos(z*0.017453292)); } vec3& vec3::Tan2() { return V3(tan(x*0.017453292), tan(y*0.017453292), tan(z*0.017453292)); } vec3& vec3::ASin2() { return V3(asin(x*0.017453292), asin(y*0.017453292), asin(z*0.017453292)); } vec3& vec3::ACos2() { return V3(acos(x*0.017453292), acos(y*0.017453292), acos(z*0.017453292)); } vec3& vec3::ATan2() { return V3(atan(x*0.017453292), atan(y*0.017453292), atan(z*0.017453292)); } vec3& vec3::Floor() { return V3(floor(x), floor(y), floor(z)); } vec3&vec3::Ceil() { return V3(ceil(x), ceil(y), ceil(z)); } vec3&vec3::Sqrt() { return V3(sqrt(x), sqrt(y), sqrt(z)); } vec3& vec3::operator()(float xx, float yy, float zz) { return V3(xx, yy, zz); } bool vec3::Closer(V3&line1, V3&line2) { return (line1.DistanceSquared(vec3(x, y, z)) < line2.DistanceSquared(vec3(x, y, z))); } vec3&vec3::vrand(V3&max) { float diff = (max.x - x) + (max.y - y) + (max.z - z); srand(time(0) * (int)(time(0) % (int)diff)); return V3(rand() + int(x)+1 % int(max.x)+1, rand() + int(y)+1 % int(max.y)+1, rand() + int(z)+1); } vec3&vec3::Lerp(V3&vec, float lerp)//Seems a lil buggy to me, use with caution { return ((V3(x, y, z) - vec) * lerp) + V3(x, y, z); } #pragma endregion //Vector4 still in the works, trying to find some good stuff to include into the class. ///////////////////////// Examples ////////////////////////// /* vec2 vec(0x820000000); //vec will now hold the single precision value of the 2d dynamic array from the current memory pool vec *= 10; //This will multiply each element of the 2d vec with 10, and store it back into itself. vec--; //this will decrease each element vec.memset(0x820001234); //this will set the 2d vec we recently read and set it to a new 2d single precision array vec3 vec(123, 456, 789); //vec will each the 3d vector of each argument, in the exact same order, (x, y, z) if(vec == getOrigin()){ ... } //I have logical operator support, this will return true if each element of vec holds the same value as- //what it inside the object getOrigin. vec <<= 16; //I added bitwise support. Normally bitwise operations aren't supported outside of integral data types, but I have added support. //This will shift each element of vec left by 16 bits, leaving the result looking like (8060928.0, 29884416, 51707904.0) vec |= 10; //This will OR 10 to each element of the vector. The result in this example looking like (80600938.0, 29884426.0, 51707914.0) vec.memset(0x81234567); //Set the 3d vector into a dynamic 3d single precision array in memory */
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
✅ Changelly.com Exploit
4 min ago | 0.28 KB
Trading method
CSS | 17 min ago | 0.28 KB
Google Docs - Exploit
30 min ago | 0.28 KB
Earn money on Changelly
CSS | 43 min ago | 0.28 KB
SwapEngine Bug [build 1.3]
57 min ago | 0.28 KB
Untitled
C | 9 hours ago | 0.88 KB
acg
1 day ago | 0.05 KB
AI METHODS
2 days ago | 0.29 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!