Matrix: add copyTo copying data to an array and copyToColumnMajor which does the same but with column-major order

same functionality explicitly for quaternions can be deleted
This commit is contained in:
Matthias Grob
2017-11-16 04:42:54 +01:00
parent 3bd94fcd6f
commit 1dffd5930b
2 changed files with 16 additions and 14 deletions
+16
View File
@@ -82,6 +82,22 @@ public:
return (*this);
}
void copyTo(Type (&dst)[M*N]) const
{
memcpy(dst, _data, sizeof(dst));
}
void copyToColumnMajor(Type (&dst)[M*N]) const
{
const Matrix<Type, M, N> &self = *this;
for (size_t i = 0; i < M; i++) {
for (size_t j = 0; j < N; j++) {
dst[i+(j*M)] = self(i, j);
}
}
}
/**
* Matrix Operations
*/