Add vector constructors (#115)

This commit is contained in:
maybegreat48 2023-05-09 20:18:42 +00:00 committed by GitHub
parent 57548ccd87
commit 9de17746d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,44 +2,86 @@
namespace rage
{
template<typename T>
union vector2
{
T data[2];
struct { T x, y; };
};
template<typename T>
union vector2
{
T data[2];
struct { T x, y; };
template<typename T>
union vector3
{
T data[3];
struct { T x, y, z; };
};
vector2(T x, T y) :
x(x),
y(y)
{
}
template<typename T>
union vector4
{
T data[4];
struct { T x, y, z, w; };
};
vector2() :
x(),
y()
{
}
};
template<typename T>
union matrix34
{
T data[3][4];
struct { struct {T x, y, z, w; } rows[3];};
};
template<typename T>
union vector3
{
T data[3];
struct { T x, y, z; };
template<typename T>
union matrix44
{
T data[4][4];
struct { struct {T x, y, z, w; } rows[4];};
};
vector3(T x, T y, T z) :
x(x),
y(y),
z(z)
{
}
typedef vector2<float> fvector2;
typedef vector3<float> fvector3;
typedef vector4<float> fvector4;
typedef matrix34<float> fmatrix34;
typedef matrix44<float> fmatrix44;
vector3() :
x(),
y(),
z()
{
}
};
template<typename T>
union vector4
{
T data[4];
struct { T x, y, z, w; };
vector4(T x, T y, T z, T w) :
x(x),
y(y),
z(z),
w(w)
{
}
vector4() :
x(),
y(),
z(),
w()
{
}
};
template<typename T>
union matrix34
{
T data[3][4];
struct { struct { T x, y, z, w; } rows[3]; };
};
template<typename T>
union matrix44
{
T data[4][4];
struct { struct { T x, y, z, w; } rows[4]; };
};
typedef vector2<float> fvector2;
typedef vector3<float> fvector3;
typedef vector4<float> fvector4;
typedef matrix34<float> fmatrix34;
typedef matrix44<float> fmatrix44;
}