matrix: add point multiplication
This commit is contained in:
parent
dadfe6173e
commit
616f6f1db9
15
matrix.cpp
15
matrix.cpp
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "matrix.hpp"
|
#include "matrix.hpp"
|
||||||
|
|
||||||
|
#include "point.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -315,6 +316,20 @@ matrix<T>::operator* (const vector<4,T> &rhs) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
point<4,T>
|
||||||
|
matrix<T>::operator* (const point<4,T> &rhs) const
|
||||||
|
{
|
||||||
|
return point<4,T> {
|
||||||
|
values[0][0] * rhs.x + values[0][1] * rhs.y + values[0][2] * rhs.z + values[0][3] * rhs.w,
|
||||||
|
values[1][0] * rhs.x + values[1][1] * rhs.y + values[1][2] * rhs.z + values[1][3] * rhs.w,
|
||||||
|
values[2][0] * rhs.x + values[2][1] * rhs.y + values[2][2] * rhs.z + values[2][3] * rhs.w,
|
||||||
|
values[3][0] * rhs.x + values[3][1] * rhs.y + values[3][2] * rhs.z + values[3][3] * rhs.w
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
matrix<T>&
|
matrix<T>&
|
||||||
|
@ -44,6 +44,7 @@ namespace util {
|
|||||||
|
|
||||||
matrix<T> operator* (const matrix<T>&) const;
|
matrix<T> operator* (const matrix<T>&) const;
|
||||||
vector<4,T> operator* (const vector<4,T>&) const;
|
vector<4,T> operator* (const vector<4,T>&) const;
|
||||||
|
point<4,T> operator* (const point<4,T> &) const;
|
||||||
|
|
||||||
matrix<T>& operator*= (T);
|
matrix<T>& operator*= (T);
|
||||||
matrix<T> operator/ (T) const;
|
matrix<T> operator/ (T) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user