diff --git a/amsmathutil25_vec_conversions.cpp.tmp b/amsmathutil25_vec_conversions.cpp.tmp new file mode 100644 index 0000000..3b538dd --- /dev/null +++ b/amsmathutil25_vec_conversions.cpp.tmp @@ -0,0 +1,504 @@ +vec2::vec2(const vec3 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec4 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec2f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec3f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec4f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec2i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec3i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec4i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec2 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec4 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec2f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec3f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec4f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec2i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec3i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec4i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec2 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec3 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec2f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec3f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec4f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec2i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec3i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec4i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2f::vec2f(const vec2 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec3 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec4 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec3f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec4f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec2i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec3i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec4i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec2 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec3 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec4 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec2f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec4f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec2i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec3i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec4i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec2 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec3 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec4 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec2f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec3f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec2i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec3i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec4i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2i::vec2i(const vec2 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec3 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec4 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec2f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec3f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec4f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec3i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec4i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec2 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec3 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec4 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec2f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec3f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec4f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec2i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec4i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec2 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec3 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec4 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec2f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec3f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec4f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec2i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec3i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + diff --git a/amsmathutil25_vec_conversions.hpp.tmp b/amsmathutil25_vec_conversions.hpp.tmp new file mode 100644 index 0000000..6d3597a --- /dev/null +++ b/amsmathutil25_vec_conversions.hpp.tmp @@ -0,0 +1,81 @@ +explicit vec2::vec2(const vec3 rhs); +explicit vec2::vec2(const vec4 rhs); +explicit vec2::vec2(const vec2f rhs); +explicit vec2::vec2(const vec3f rhs); +explicit vec2::vec2(const vec4f rhs); +explicit vec2::vec2(const vec2i rhs); +explicit vec2::vec2(const vec3i rhs); +explicit vec2::vec2(const vec4i rhs); + +explicit vec3::vec3(const vec2 rhs); +explicit vec3::vec3(const vec4 rhs); +explicit vec3::vec3(const vec2f rhs); +explicit vec3::vec3(const vec3f rhs); +explicit vec3::vec3(const vec4f rhs); +explicit vec3::vec3(const vec2i rhs); +explicit vec3::vec3(const vec3i rhs); +explicit vec3::vec3(const vec4i rhs); + +explicit vec4::vec4(const vec2 rhs); +explicit vec4::vec4(const vec3 rhs); +explicit vec4::vec4(const vec2f rhs); +explicit vec4::vec4(const vec3f rhs); +explicit vec4::vec4(const vec4f rhs); +explicit vec4::vec4(const vec2i rhs); +explicit vec4::vec4(const vec3i rhs); +explicit vec4::vec4(const vec4i rhs); + +explicit vec2f::vec2f(const vec2 rhs); +explicit vec2f::vec2f(const vec3 rhs); +explicit vec2f::vec2f(const vec4 rhs); +explicit vec2f::vec2f(const vec3f rhs); +explicit vec2f::vec2f(const vec4f rhs); +explicit vec2f::vec2f(const vec2i rhs); +explicit vec2f::vec2f(const vec3i rhs); +explicit vec2f::vec2f(const vec4i rhs); + +explicit vec3f::vec3f(const vec2 rhs); +explicit vec3f::vec3f(const vec3 rhs); +explicit vec3f::vec3f(const vec4 rhs); +explicit vec3f::vec3f(const vec2f rhs); +explicit vec3f::vec3f(const vec4f rhs); +explicit vec3f::vec3f(const vec2i rhs); +explicit vec3f::vec3f(const vec3i rhs); +explicit vec3f::vec3f(const vec4i rhs); + +explicit vec4f::vec4f(const vec2 rhs); +explicit vec4f::vec4f(const vec3 rhs); +explicit vec4f::vec4f(const vec4 rhs); +explicit vec4f::vec4f(const vec2f rhs); +explicit vec4f::vec4f(const vec3f rhs); +explicit vec4f::vec4f(const vec2i rhs); +explicit vec4f::vec4f(const vec3i rhs); +explicit vec4f::vec4f(const vec4i rhs); + +explicit vec2i::vec2i(const vec2 rhs); +explicit vec2i::vec2i(const vec3 rhs); +explicit vec2i::vec2i(const vec4 rhs); +explicit vec2i::vec2i(const vec2f rhs); +explicit vec2i::vec2i(const vec3f rhs); +explicit vec2i::vec2i(const vec4f rhs); +explicit vec2i::vec2i(const vec3i rhs); +explicit vec2i::vec2i(const vec4i rhs); + +explicit vec3i::vec3i(const vec2 rhs); +explicit vec3i::vec3i(const vec3 rhs); +explicit vec3i::vec3i(const vec4 rhs); +explicit vec3i::vec3i(const vec2f rhs); +explicit vec3i::vec3i(const vec3f rhs); +explicit vec3i::vec3i(const vec4f rhs); +explicit vec3i::vec3i(const vec2i rhs); +explicit vec3i::vec3i(const vec4i rhs); + +explicit vec4i::vec4i(const vec2 rhs); +explicit vec4i::vec4i(const vec3 rhs); +explicit vec4i::vec4i(const vec4 rhs); +explicit vec4i::vec4i(const vec2f rhs); +explicit vec4i::vec4i(const vec3f rhs); +explicit vec4i::vec4i(const vec4f rhs); +explicit vec4i::vec4i(const vec2i rhs); +explicit vec4i::vec4i(const vec3i rhs); + diff --git a/build_linux64/libamsmathutil25.linux64.a b/build_linux64/libamsmathutil25.linux64.a index b4b1f64..6996fbd 100644 Binary files a/build_linux64/libamsmathutil25.linux64.a and b/build_linux64/libamsmathutil25.linux64.a differ diff --git a/build_linux64/objstore/amsmathutil25_vec2i.o b/build_linux64/objstore/amsmathutil25_vec2i.o new file mode 100644 index 0000000..8cef38f Binary files /dev/null and b/build_linux64/objstore/amsmathutil25_vec2i.o differ diff --git a/build_linux64/objstore/amsmathutil25_vec3i.o b/build_linux64/objstore/amsmathutil25_vec3i.o new file mode 100644 index 0000000..de0ddec Binary files /dev/null and b/build_linux64/objstore/amsmathutil25_vec3i.o differ diff --git a/build_linux64/objstore/amsmathutil25_vec4i.o b/build_linux64/objstore/amsmathutil25_vec4i.o new file mode 100644 index 0000000..de440a4 Binary files /dev/null and b/build_linux64/objstore/amsmathutil25_vec4i.o differ diff --git a/build_linux64/objstore/amsmathutil25_vecconversions.o b/build_linux64/objstore/amsmathutil25_vecconversions.o new file mode 100644 index 0000000..93bba8f Binary files /dev/null and b/build_linux64/objstore/amsmathutil25_vecconversions.o differ diff --git a/include/amsmathutil25/math/amsmathutil25_math.hpp b/include/amsmathutil25/math/amsmathutil25_math.hpp index bb20a19..b10d7db 100644 --- a/include/amsmathutil25/math/amsmathutil25_math.hpp +++ b/include/amsmathutil25/math/amsmathutil25_math.hpp @@ -23,6 +23,7 @@ static const double vecmat_det_small = 1.0E-15; }; //end namespace ams +#include #include #include #include @@ -32,6 +33,9 @@ static const double vecmat_det_small = 1.0E-15; #include #include #include +#include +#include +#include #endif diff --git a/include/amsmathutil25/math/amsmathutil25_mathpredeclare.hpp b/include/amsmathutil25/math/amsmathutil25_mathpredeclare.hpp new file mode 100644 index 0000000..7766e59 --- /dev/null +++ b/include/amsmathutil25/math/amsmathutil25_mathpredeclare.hpp @@ -0,0 +1,33 @@ +#ifndef __AMSMATHUTIL25_MATHPREDECLARE_HPP__ +#define __AMSMATHUTIL25_MATHPREDECLARE_HPP__ + +namespace ams +{ + + //Pre-declarations for interconversion + + class vec2; + class vec2f; + class mat2; + class mat2f; + + class vec2i; + + class vec3; + class vec3f; + class mat3; + class mat3f; + + class vec3i; + + class vec4; + class vec4f; + class mat4; + class mat4f; + + class vec4i; + + +}; + +#endif \ No newline at end of file diff --git a/include/amsmathutil25/math/amsmathutil25_vec2.hpp b/include/amsmathutil25/math/amsmathutil25_vec2.hpp index c132286..ebc20fc 100644 --- a/include/amsmathutil25/math/amsmathutil25_vec2.hpp +++ b/include/amsmathutil25/math/amsmathutil25_vec2.hpp @@ -24,6 +24,16 @@ public: double& operator[](int ind); const double& operator[](int ind) const; + + //explicit conversions for casting + explicit vec2(const vec3 rhs); + explicit vec2(const vec4 rhs); + explicit vec2(const vec2f rhs); + explicit vec2(const vec3f rhs); + explicit vec2(const vec4f rhs); + explicit vec2(const vec2i rhs); + explicit vec2(const vec3i rhs); + explicit vec2(const vec4i rhs); }; //vector operations diff --git a/include/amsmathutil25/math/amsmathutil25_vec2f.hpp b/include/amsmathutil25/math/amsmathutil25_vec2f.hpp index 883552d..bb6631f 100644 --- a/include/amsmathutil25/math/amsmathutil25_vec2f.hpp +++ b/include/amsmathutil25/math/amsmathutil25_vec2f.hpp @@ -24,6 +24,16 @@ public: float& operator[](int ind); const float& operator[](int ind) const; + + //explicit conversions for casting + explicit vec2f(const vec2 rhs); + explicit vec2f(const vec3 rhs); + explicit vec2f(const vec4 rhs); + explicit vec2f(const vec3f rhs); + explicit vec2f(const vec4f rhs); + explicit vec2f(const vec2i rhs); + explicit vec2f(const vec3i rhs); + explicit vec2f(const vec4i rhs); }; //vector operations diff --git a/include/amsmathutil25/math/amsmathutil25_vec2i.hpp b/include/amsmathutil25/math/amsmathutil25_vec2i.hpp index 205cbe0..88bad83 100644 --- a/include/amsmathutil25/math/amsmathutil25_vec2i.hpp +++ b/include/amsmathutil25/math/amsmathutil25_vec2i.hpp @@ -11,21 +11,33 @@ public: int y; vec2i(); - vec2i(float _x, float _y); + vec2i(int _x, int _y); vec2i(const vec2i &rhs); vec2i& operator=(const vec2i &rhs); bool operator==(const vec2i rhs) const; vec2i operator+(vec2i rhs) const; vec2i operator-(vec2i rhs) const; - vec2i operator*(float rhs) const; - vec2i operator/(float rhs) const; + vec2i operator*(int rhs) const; + vec2i operator/(int rhs) const; friend vec2i operator-(vec2i rhs); - float& operator[](int ind); - const float& operator[](int ind) const; + int& operator[](int ind); + const int& operator[](int ind) const; + + //explicit conversion constructors for casting + explicit vec2i(const vec2 rhs); + explicit vec2i(const vec3 rhs); + explicit vec2i(const vec4 rhs); + explicit vec2i(const vec2f rhs); + explicit vec2i(const vec3f rhs); + explicit vec2i(const vec4f rhs); + explicit vec2i(const vec3i rhs); + explicit vec2i(const vec4i rhs); }; }; + +#endif \ No newline at end of file diff --git a/include/amsmathutil25/math/amsmathutil25_vec3.hpp b/include/amsmathutil25/math/amsmathutil25_vec3.hpp index 9d20220..58d0766 100644 --- a/include/amsmathutil25/math/amsmathutil25_vec3.hpp +++ b/include/amsmathutil25/math/amsmathutil25_vec3.hpp @@ -29,6 +29,16 @@ public: double& operator[](int ind); const double& operator[](int ind) const; + + //explicit conversion constructors for casting + explicit vec3(const vec2 rhs); + explicit vec3(const vec4 rhs); + explicit vec3(const vec2f rhs); + explicit vec3(const vec3f rhs); + explicit vec3(const vec4f rhs); + explicit vec3(const vec2i rhs); + explicit vec3(const vec3i rhs); + explicit vec3(const vec4i rhs); }; //vector operations diff --git a/include/amsmathutil25/math/amsmathutil25_vec3f.hpp b/include/amsmathutil25/math/amsmathutil25_vec3f.hpp index 85a4e25..e9d3c2c 100644 --- a/include/amsmathutil25/math/amsmathutil25_vec3f.hpp +++ b/include/amsmathutil25/math/amsmathutil25_vec3f.hpp @@ -29,6 +29,16 @@ public: float& operator[](int ind); const float& operator[](int ind) const; + + //explicit conversion constructors for casting + explicit vec3f(const vec2 rhs); + explicit vec3f(const vec3 rhs); + explicit vec3f(const vec4 rhs); + explicit vec3f(const vec2f rhs); + explicit vec3f(const vec4f rhs); + explicit vec3f(const vec2i rhs); + explicit vec3f(const vec3i rhs); + explicit vec3f(const vec4i rhs); }; //vector operations diff --git a/include/amsmathutil25/math/amsmathutil25_vec3i.hpp b/include/amsmathutil25/math/amsmathutil25_vec3i.hpp new file mode 100644 index 0000000..43e1ea8 --- /dev/null +++ b/include/amsmathutil25/math/amsmathutil25_vec3i.hpp @@ -0,0 +1,45 @@ +#ifndef __AMSMATHUTIL25_VEC3I_HPP__ +#define __AMSMATHUTIL25_VEC3I_HPP__ + +namespace ams +{ + +class vec3i +{ +public: + int x; + int y; + int z; + + vec3i(); + vec3i(int _x, int _y, int z); + vec3i(const vec3i &rhs); + vec3i& operator=(const vec3i &rhs); + bool operator==(const vec3i rhs) const; + + vec3i operator+(vec3i rhs) const; + vec3i operator-(vec3i rhs) const; + vec3i operator*(int rhs) const; + vec3i operator/(int rhs) const; + friend vec3i operator-(vec3i rhs); + + int& operator[](int ind); + const int& operator[](int ind) const; + + //explicit conversion constructors for casting + explicit vec3i(const vec2 rhs); + explicit vec3i(const vec3 rhs); + explicit vec3i(const vec4 rhs); + explicit vec3i(const vec2f rhs); + explicit vec3i(const vec3f rhs); + explicit vec3i(const vec4f rhs); + explicit vec3i(const vec2i rhs); + explicit vec3i(const vec4i rhs); + +}; + + + +}; + +#endif \ No newline at end of file diff --git a/include/amsmathutil25/math/amsmathutil25_vec4.hpp b/include/amsmathutil25/math/amsmathutil25_vec4.hpp index 022b76a..9676bd2 100644 --- a/include/amsmathutil25/math/amsmathutil25_vec4.hpp +++ b/include/amsmathutil25/math/amsmathutil25_vec4.hpp @@ -29,6 +29,17 @@ public: double& operator[](int ind); const double& operator[](int ind) const; + + //explicit conversion constructors for casting + explicit vec4(const vec2 rhs); + explicit vec4(const vec3 rhs); + explicit vec4(const vec2f rhs); + explicit vec4(const vec3f rhs); + explicit vec4(const vec4f rhs); + explicit vec4(const vec2i rhs); + explicit vec4(const vec3i rhs); + explicit vec4(const vec4i rhs); + }; //vector operations diff --git a/include/amsmathutil25/math/amsmathutil25_vec4f.hpp b/include/amsmathutil25/math/amsmathutil25_vec4f.hpp index 070b62d..ecc57eb 100644 --- a/include/amsmathutil25/math/amsmathutil25_vec4f.hpp +++ b/include/amsmathutil25/math/amsmathutil25_vec4f.hpp @@ -29,6 +29,17 @@ public: float& operator[](int ind); const float& operator[](int ind) const; + + //explicit conversion constructors for casting + explicit vec4f(const vec2 rhs); + explicit vec4f(const vec3 rhs); + explicit vec4f(const vec4 rhs); + explicit vec4f(const vec2f rhs); + explicit vec4f(const vec3f rhs); + explicit vec4f(const vec2i rhs); + explicit vec4f(const vec3i rhs); + explicit vec4f(const vec4i rhs); + }; //vector operations diff --git a/include/amsmathutil25/math/amsmathutil25_vec4i.hpp b/include/amsmathutil25/math/amsmathutil25_vec4i.hpp new file mode 100644 index 0000000..6cc4643 --- /dev/null +++ b/include/amsmathutil25/math/amsmathutil25_vec4i.hpp @@ -0,0 +1,47 @@ +#ifndef __AMSMATHUTIL25_VEC4I_HPP__ +#define __AMSMATHUTIL25_VEC4I_HPP__ + +namespace ams +{ + +class vec4i +{ +public: + int x; + int y; + int z; + int w; + + vec4i(); + vec4i(int _x, int _y, int _z, int _w); + vec4i(const vec4i &rhs); + vec4i& operator=(const vec4i &rhs); + bool operator==(const vec4i rhs) const; + + vec4i operator+(vec4i rhs) const; + vec4i operator-(vec4i rhs) const; + vec4i operator*(int rhs) const; + vec4i operator/(int rhs) const; + friend vec4i operator-(vec4i rhs); + + int& operator[](int ind); + const int& operator[](int ind) const; + + //explicit conversion constructors for casting + explicit vec4i(const vec2 rhs); + explicit vec4i(const vec3 rhs); + explicit vec4i(const vec4 rhs); + explicit vec4i(const vec2f rhs); + explicit vec4i(const vec3f rhs); + explicit vec4i(const vec4f rhs); + explicit vec4i(const vec2i rhs); + explicit vec4i(const vec3i rhs); + + +}; + + + +}; + +#endif \ No newline at end of file diff --git a/include/amsmathutil25/math/genconversions.py b/include/amsmathutil25/math/genconversions.py new file mode 100644 index 0000000..7abc843 --- /dev/null +++ b/include/amsmathutil25/math/genconversions.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 + +import os,sys,math +import numpy as np + + + +dtype = ['d','f','i'] +dtxt = ['','f','i'] +convtxt = ['double','float','int'] +dim = [2,3,4] + +headertxt = "" +bodytxt = "" + +for I in range(0,len(dtype)): + for J in range(0,len(dim)): + for K in range(0,len(dtype)): + for L in range(0,len(dim)): + if(I==K and J==L): + continue + else: + #generate a converter + ttxt = "vec{:d}{:s}".format(dim[J],dtxt[I]) + ftxt = "vec{:d}{:s}".format(dim[L],dtxt[K]) + + + + body = "" + body += "{}::{}(const {} rhs)\n".format(ttxt,ttxt,ftxt) + body += "{\n" + body += " x = ({})rhs.x;\n".format(convtxt[I]) + body += " y = ({})rhs.y;\n".format(convtxt[I]) + if(J>=3): + if(L>=3): + body += " z = ({})rhs.z;\n".format(convtxt[I]) + else: + body += " z = 0;\n".format(convtxt[I]) + if(J>=4): + if(L>=4): + body += " w = ({})rhs.w;\n".format(convtxt[I]) + else: + body += " w = 0;\n".format(convtxt[I]) + body += " return;\n" + body += "}\n\n" + + + head = "explicit {}::{}(const {} rhs);\n".format(ttxt,ttxt,ftxt) + + headertxt+=head + bodytxt+=body + + headertxt+="\n" + + +fp = open("./amsmathutil25_vec_conversions.hpp.tmp","w+") +fp.write(headertxt) +fp.close() +fp = open("./amsmathutil25_vec_conversions.cpp.tmp","w+") +fp.write(bodytxt) +fp.close() + + diff --git a/src/amsmathutil25/math/amsmathutil25_vec2i.cpp b/src/amsmathutil25/math/amsmathutil25_vec2i.cpp new file mode 100644 index 0000000..1039f3d --- /dev/null +++ b/src/amsmathutil25/math/amsmathutil25_vec2i.cpp @@ -0,0 +1,108 @@ +#include + +namespace ams +{ + + vec2i::vec2i() + { + x = 0; + y = 0; + return; + } + + vec2i::vec2i(int _x, int _y) + { + x = _x; y = _y; return; + } + + vec2i::vec2i(const vec2i &rhs) + { + x = rhs.x; + y = rhs.y; + return; + } + + vec2i& vec2i::operator=(const vec2i &rhs) + { + x = rhs.x; + y = rhs.y; + return *this; + } + + bool vec2i::operator==(const vec2i rhs) const + { + return ((this->x == rhs.x) && (this->y == rhs.y)); + } + + // vec2i arithmetic operators + vec2i vec2i::operator+(vec2i rhs) const + { + vec2i ret; + ret.x = this->x + rhs.x; + ret.y = this->y + rhs.y; + return ret; + } + + vec2i vec2i::operator-(vec2i rhs) const + { + vec2i ret; + ret.x = this->x - rhs.x; + ret.y = this->y - rhs.y; + return ret; + } + + vec2i vec2i::operator*(int rhs) const + { + vec2i ret; + ret.x = this->x*rhs; + ret.y = this->y*rhs; + return ret; + } + + vec2i vec2i::operator/(int rhs) const + { + vec2i ret; + ret.x = this->x/rhs; + ret.y = this->y/rhs; + return ret; + } + + vec2i operator-(vec2i rhs) + { + vec2i ret; + ret.x = -rhs.x; + ret.y = -rhs.y; + return ret; + } + + // vec2i subscript operators + int& vec2i::operator[](int ind) + { + if(ind==0) return x; + else if(ind==1) return y; + return x; + } + + const int& vec2i::operator[](int ind) const + { + if(ind==0) return x; + else if(ind==1) return y; + return x; + } + + // vec2i::vec2i(const vec2f &rhs) + // { + // x = (int)rhs.x; + // y = (int)rhs.y; + // return; + // } + + // vec2i::vec2i(const vec2 &rhs) + // { + // x = (int)rhs.x; + // y = (int)rhs.y; + // return; + // } + + +}; diff --git a/src/amsmathutil25/math/amsmathutil25_vec3i.cpp b/src/amsmathutil25/math/amsmathutil25_vec3i.cpp new file mode 100644 index 0000000..8d1dc34 --- /dev/null +++ b/src/amsmathutil25/math/amsmathutil25_vec3i.cpp @@ -0,0 +1,122 @@ +#include + +namespace ams +{ + + vec3i::vec3i() + { + x = 0; + y = 0; + return; + } + + vec3i::vec3i(int _x, int _y, int _z) + { + x = _x; y = _y; z = _z; return; + } + + vec3i::vec3i(const vec3i &rhs) + { + x = rhs.x; + y = rhs.y; + z = rhs.z; + + return; + } + + vec3i& vec3i::operator=(const vec3i &rhs) + { + x = rhs.x; + y = rhs.y; + z = rhs.z; + + return *this; + } + + bool vec3i::operator==(const vec3i rhs) const + { + return ((this->x == rhs.x) && (this->y == rhs.y) && (this->z == rhs.z)); + } + + // vec3i arithmetic operators + vec3i vec3i::operator+(vec3i rhs) const + { + vec3i ret; + ret.x = this->x + rhs.x; + ret.y = this->y + rhs.y; + ret.z = this->z + rhs.z; + return ret; + } + + vec3i vec3i::operator-(vec3i rhs) const + { + vec3i ret; + ret.x = this->x - rhs.x; + ret.y = this->y - rhs.y; + ret.z = this->z - rhs.z; + return ret; + } + + vec3i vec3i::operator*(int rhs) const + { + vec3i ret; + ret.x = this->x*rhs; + ret.y = this->y*rhs; + ret.z = this->z*rhs; + return ret; + } + + vec3i vec3i::operator/(int rhs) const + { + vec3i ret; + ret.x = this->x/rhs; + ret.y = this->y/rhs; + ret.z = this->z/rhs; + return ret; + } + + vec3i operator-(vec3i rhs) + { + vec3i ret; + ret.x = -rhs.x; + ret.y = -rhs.y; + ret.z = -rhs.z; + return ret; + } + + // vec3i subscript operators + int& vec3i::operator[](int ind) + { + if(ind==0) return x; + else if(ind==1) return y; + else if(ind==2) return z; + return x; + } + + const int& vec3i::operator[](int ind) const + { + if(ind==0) return x; + else if(ind==1) return y; + else if(ind==2) return z; + return x; + } + + + // vec3i::vec3i(const vec3f &rhs) + // { + // x = (int)rhs.x; + // y = (int)rhs.y; + // z = (int)rhs.z; + // return; + // } + + // vec3i::vec3i(const vec3 &rhs) + // { + // x = (int)rhs.x; + // y = (int)rhs.y; + // z = (int)rhs.z; + // return; + // } + + +}; diff --git a/src/amsmathutil25/math/amsmathutil25_vec4f.cpp b/src/amsmathutil25/math/amsmathutil25_vec4f.cpp index e0a21d5..30d72fa 100644 --- a/src/amsmathutil25/math/amsmathutil25_vec4f.cpp +++ b/src/amsmathutil25/math/amsmathutil25_vec4f.cpp @@ -612,4 +612,7 @@ mat4f mat4f_transpose(mat4f a) return a.transpose(); } + + + }; \ No newline at end of file diff --git a/src/amsmathutil25/math/amsmathutil25_vec4i.cpp b/src/amsmathutil25/math/amsmathutil25_vec4i.cpp new file mode 100644 index 0000000..f5ac2a4 --- /dev/null +++ b/src/amsmathutil25/math/amsmathutil25_vec4i.cpp @@ -0,0 +1,131 @@ +#include + +namespace ams +{ + + vec4i::vec4i() + { + x = 0; + y = 0; + return; + } + + vec4i::vec4i(int _x, int _y, int _z, int _w) + { + x = _x; y = _y; z = _z; w = _w; return; + } + + vec4i::vec4i(const vec4i &rhs) + { + x = rhs.x; + y = rhs.y; + z = rhs.z; + w = rhs.w; + + return; + } + + vec4i& vec4i::operator=(const vec4i &rhs) + { + x = rhs.x; + y = rhs.y; + z = rhs.z; + w = rhs.w; + + return *this; + } + + bool vec4i::operator==(const vec4i rhs) const + { + return ((this->x == rhs.x) && (this->y == rhs.y) && (this->z == rhs.z) && (this->w == rhs.w)); + } + + // vec4i arithmetic operators + vec4i vec4i::operator+(vec4i rhs) const + { + vec4i ret; + ret.x = this->x + rhs.x; + ret.y = this->y + rhs.y; + ret.z = this->z + rhs.z; + ret.w = this->w + rhs.w; + return ret; + } + + vec4i vec4i::operator-(vec4i rhs) const + { + vec4i ret; + ret.x = this->x - rhs.x; + ret.y = this->y - rhs.y; + ret.z = this->z - rhs.z; + ret.w = this->w - rhs.w; + return ret; + } + + vec4i vec4i::operator*(int rhs) const + { + vec4i ret; + ret.x = this->x*rhs; + ret.y = this->y*rhs; + ret.z = this->z*rhs; + ret.w = this->w*rhs; + return ret; + } + + vec4i vec4i::operator/(int rhs) const + { + vec4i ret; + ret.x = this->x/rhs; + ret.y = this->y/rhs; + ret.z = this->z/rhs; + ret.w = this->w/rhs; + return ret; + } + + vec4i operator-(vec4i rhs) + { + vec4i ret; + ret.x = -rhs.x; + ret.y = -rhs.y; + ret.z = -rhs.z; + ret.w = -rhs.w; + return ret; + } + + // vec4i subscript operators + int& vec4i::operator[](int ind) + { + if(ind==0) return x; + else if(ind==1) return y; + else if(ind==2) return z; + else if(ind==3) return w; + return x; + } + + const int& vec4i::operator[](int ind) const + { + if(ind==0) return x; + else if(ind==1) return y; + else if(ind==2) return z; + else if(ind==3) return w; + return x; + } + + // vec4i::vec4i(const vec4f &rhs) + // { + // x = (int)rhs.x; + // y = (int)rhs.y; + // z = (int)rhs.z; + // w = (int)rhs.w; + // return; + // } + + // vec4i::vec4i(const vec4 &rhs) + // { + // x = (int)rhs.x; + // y = (int)rhs.y; + // z = (int)rhs.z; + // w = (int)rhs.w; + // return; + // } + +}; diff --git a/src/amsmathutil25/math/amsmathutil25_vecconversions.cpp b/src/amsmathutil25/math/amsmathutil25_vecconversions.cpp new file mode 100644 index 0000000..2614dd8 --- /dev/null +++ b/src/amsmathutil25/math/amsmathutil25_vecconversions.cpp @@ -0,0 +1,512 @@ +#include + +namespace ams +{ + + vec2::vec2(const vec3 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec4 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec2f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec3f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec4f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec2i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec3i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2::vec2(const vec4i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec2 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec4 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec2f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec3f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec4f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec2i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec3i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec3::vec3(const vec4i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec2 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec3 rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec2f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec3f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec4f rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec2i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec3i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec4::vec4(const vec4i rhs) +{ + x = (double)rhs.x; + y = (double)rhs.y; + return; +} + +vec2f::vec2f(const vec2 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec3 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec4 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec3f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec4f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec2i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec3i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2f::vec2f(const vec4i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec2 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec3 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec4 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec2f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec4f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec2i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec3i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec3f::vec3f(const vec4i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec2 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec3 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec4 rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec2f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec3f rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec2i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec3i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec4f::vec4f(const vec4i rhs) +{ + x = (float)rhs.x; + y = (float)rhs.y; + return; +} + +vec2i::vec2i(const vec2 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec3 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec4 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec2f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec3f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec4f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec3i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec2i::vec2i(const vec4i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec2 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec3 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec4 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec2f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec3f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec4f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec2i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec3i::vec3i(const vec4i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec2 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec3 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec4 rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec2f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec3f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec4f rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec2i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + +vec4i::vec4i(const vec3i rhs) +{ + x = (int)rhs.x; + y = (int)rhs.y; + return; +} + + + +}; \ No newline at end of file