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,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;
}

View File

@ -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);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -23,6 +23,7 @@ static const double vecmat_det_small = 1.0E-15;
}; //end namespace ams }; //end namespace ams
#include <amsmathutil25/math/amsmathutil25_mathpredeclare.hpp>
#include <amsmathutil25/math/amsmathutil25_mathfns1.hpp> #include <amsmathutil25/math/amsmathutil25_mathfns1.hpp>
#include <amsmathutil25/math/amsmathutil25_complex64.hpp> #include <amsmathutil25/math/amsmathutil25_complex64.hpp>
#include <amsmathutil25/math/amsmathutil25_complex128.hpp> #include <amsmathutil25/math/amsmathutil25_complex128.hpp>
@ -32,6 +33,9 @@ static const double vecmat_det_small = 1.0E-15;
#include <amsmathutil25/math/amsmathutil25_vec2f.hpp> #include <amsmathutil25/math/amsmathutil25_vec2f.hpp>
#include <amsmathutil25/math/amsmathutil25_vec3f.hpp> #include <amsmathutil25/math/amsmathutil25_vec3f.hpp>
#include <amsmathutil25/math/amsmathutil25_vec4f.hpp> #include <amsmathutil25/math/amsmathutil25_vec4f.hpp>
#include <amsmathutil25/math/amsmathutil25_vec2i.hpp>
#include <amsmathutil25/math/amsmathutil25_vec3i.hpp>
#include <amsmathutil25/math/amsmathutil25_vec4i.hpp>
#endif #endif

View File

@ -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

View File

@ -24,6 +24,16 @@ public:
double& operator[](int ind); double& operator[](int ind);
const double& operator[](int ind) const; 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 //vector operations

View File

@ -24,6 +24,16 @@ public:
float& operator[](int ind); float& operator[](int ind);
const float& operator[](int ind) const; 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 //vector operations

View File

@ -11,21 +11,33 @@ public:
int y; int y;
vec2i(); vec2i();
vec2i(float _x, float _y); vec2i(int _x, int _y);
vec2i(const vec2i &rhs); vec2i(const vec2i &rhs);
vec2i& operator=(const vec2i &rhs); vec2i& operator=(const vec2i &rhs);
bool operator==(const vec2i rhs) const; bool operator==(const vec2i rhs) const;
vec2i operator+(vec2i rhs) const; vec2i operator+(vec2i rhs) const;
vec2i operator-(vec2i rhs) const; vec2i operator-(vec2i rhs) const;
vec2i operator*(float rhs) const; vec2i operator*(int rhs) const;
vec2i operator/(float rhs) const; vec2i operator/(int rhs) const;
friend vec2i operator-(vec2i rhs); friend vec2i operator-(vec2i rhs);
float& operator[](int ind); int& operator[](int ind);
const float& operator[](int ind) const; 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

View File

@ -29,6 +29,16 @@ public:
double& operator[](int ind); double& operator[](int ind);
const double& operator[](int ind) const; 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 //vector operations

View File

@ -29,6 +29,16 @@ public:
float& operator[](int ind); float& operator[](int ind);
const float& operator[](int ind) const; 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 //vector operations

View File

@ -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

View File

@ -29,6 +29,17 @@ public:
double& operator[](int ind); double& operator[](int ind);
const double& operator[](int ind) const; 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 //vector operations

View File

@ -29,6 +29,17 @@ public:
float& operator[](int ind); float& operator[](int ind);
const float& operator[](int ind) const; 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 //vector operations

View File

@ -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

View File

@ -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()

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(); 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;
}
};