matrix: add transpose functions
This commit is contained in:
parent
a198aa1cba
commit
253be704cb
26
matrix.cpp
26
matrix.cpp
@ -48,6 +48,32 @@ matrix<T>::translate (T x, T y, T z) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
matrix<T>
|
||||||
|
matrix<T>::transposed (void) const
|
||||||
|
{
|
||||||
|
matrix<T> m;
|
||||||
|
for (size_t i = 0; i < 4; ++i)
|
||||||
|
for (size_t j = 0; j < 4; ++j)
|
||||||
|
m.values[i][j] = values[j][i];
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
matrix<T>&
|
||||||
|
matrix<T>::transpose (void)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < 4; ++i)
|
||||||
|
for (size_t j = i + 1; j < 4; ++j)
|
||||||
|
std::swap (values[i][j], values[j][i]);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
matrix<T>
|
matrix<T>
|
||||||
|
@ -35,6 +35,9 @@ namespace util {
|
|||||||
void scale (T x, T y, T z);
|
void scale (T x, T y, T z);
|
||||||
void translate (T x, T y, T z);
|
void translate (T x, T y, T z);
|
||||||
|
|
||||||
|
matrix& transpose (void);
|
||||||
|
matrix transposed (void) const;
|
||||||
|
|
||||||
matrix<T> inverse (void) const;
|
matrix<T> inverse (void) const;
|
||||||
matrix<T>& invert (void);
|
matrix<T>& invert (void);
|
||||||
matrix<T> inverse_affine (void) const;
|
matrix<T> inverse_affine (void) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user