added vector interconversions

This commit is contained in:
2026-03-11 14:23:36 -04:00
parent d26c7ee348
commit 4fe50d12d0
24 changed files with 1732 additions and 5 deletions

View File

@ -0,0 +1,108 @@
#include <amsmathutil25/amsmathutil25.hpp>
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;
// }
};

View File

@ -0,0 +1,122 @@
#include <amsmathutil25/amsmathutil25.hpp>
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;
// }
};

View File

@ -612,4 +612,7 @@ mat4f mat4f_transpose(mat4f a)
return a.transpose();
}
};

View File

@ -0,0 +1,131 @@
#include <amsmathutil25/amsmathutil25.hpp>
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;
// }
};

View File

@ -0,0 +1,512 @@
#include <amsmathutil25/amsmathutil25.hpp>
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;
}
};