Initialization of Vec3, MAt3, and Quaternion from brace-enclosed list
This commit is contained in:
parent
b7d3a5d977
commit
b50f9b36b1
@ -40,6 +40,7 @@ public:
|
||||
T q[4];
|
||||
//methods
|
||||
Quaternion(void) {};
|
||||
Quaternion(const T (&a)[4]) {memcpy(q,a,4*sizeof(T));};
|
||||
Quaternion(const T x, const T u=0, const T v=0, const T w=0) {q[0]=x; q[1]=u; q[2]=v; q[3]=w;}; //quaternion from real(s)
|
||||
Quaternion(const std::complex<T> &rhs) {q[0]=rhs.real(); q[1]=rhs.imag(); q[2]=0; q[3]=0;} //quaternion from complex
|
||||
explicit Quaternion(const T* x, const int shift=1) {q[0]=0; memcpy(q+shift,x,(4-shift)*sizeof(T));} //for shift=1 quaternion from xyz vector
|
||||
|
8
t.cc
8
t.cc
@ -2298,8 +2298,16 @@ if(1)
|
||||
{
|
||||
NRVec<int> v({1,2,3,4});
|
||||
cout <<v;
|
||||
v.resize(0);
|
||||
cout<<v;
|
||||
NRMat<int> m({{1,2,3},{4,5,6}});
|
||||
cout<<m;
|
||||
Vec3<double> x({1,2,3});
|
||||
cout<<x<<endl;
|
||||
Mat3<double> y({{1,2,3},{4,5,6},{7,8,9}});
|
||||
cout <<y<<endl;
|
||||
Quaternion<double> q({1,2,3,4});
|
||||
cout<<q<<endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
Vec3(void) {};
|
||||
Vec3(const T x, const T u=0, const T v=0) {q[0]=x; q[1]=u; q[2]=v;}; //Vec3 from real(s)
|
||||
Vec3(const T* x) {memcpy(q,x,3*sizeof(T));}
|
||||
Vec3(const T (&a)[3]) {memcpy(q,a,3*sizeof(T));};
|
||||
|
||||
//get pointer to data transparently
|
||||
inline operator const T*() const {return q;};
|
||||
@ -98,6 +99,7 @@ public:
|
||||
T q[3][3];
|
||||
//
|
||||
Mat3(void) {};
|
||||
Mat3(const T (&a)[3][3]) {memcpy(q,a,3*3*sizeof(T));}
|
||||
Mat3(const T x) {memset(q,0,9*sizeof(T)); q[0][0]=q[1][1]=q[2][2]=x;}; //scalar matrix
|
||||
Mat3(const T* x) {memcpy(q,x,9*sizeof(T));}
|
||||
Mat3(const T x00, const T x01,const T x02,const T x10,const T x11,const T x12,const T x20,const T x21,const T x22)
|
||||
|
Loading…
Reference in New Issue
Block a user