Merge pull request #1207 from Celli119/matrixOperators

operators to add and multiply by floats
pull/1208/head
Kim Kulling 2017-03-17 09:33:41 +01:00 committed by GitHub
commit a182faacbf
2 changed files with 50 additions and 0 deletions

View File

@ -112,6 +112,8 @@ public:
// matrix multiplication.
aiMatrix4x4t& operator *= (const aiMatrix4x4t& m);
aiMatrix4x4t operator * (const aiMatrix4x4t& m) const;
aiMatrix4x4t operator * (const TReal& aFloat) const;
aiMatrix4x4t operator + (const aiMatrix4x4t& aMatrix) const;
template <typename TOther>
operator aiMatrix4x4t<TOther> () const;

View File

@ -155,6 +155,54 @@ inline aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::operator *= (const aiMatrix4x4t
return *this;
}
// ----------------------------------------------------------------------------------------
template <typename TReal>
inline aiMatrix4x4t<TReal> aiMatrix4x4t<TReal>::operator* (const TReal& aFloat) const
{
aiMatrix4x4t<TReal> temp(
a1 * aFloat,
a2 * aFloat,
a3 * aFloat,
a4 * aFloat,
b1 * aFloat,
b2 * aFloat,
b3 * aFloat,
b4 * aFloat,
c1 * aFloat,
c2 * aFloat,
c3 * aFloat,
c4 * aFloat,
d1 * aFloat,
d2 * aFloat,
d3 * aFloat,
d4 * aFloat);
return temp;
}
// ----------------------------------------------------------------------------------------
template <typename TReal>
inline aiMatrix4x4t<TReal> aiMatrix4x4t<TReal>::operator+ (const aiMatrix4x4t<TReal>& m) const
{
aiMatrix4x4t<TReal> temp(
m.a1 + a1,
m.a2 + a2,
m.a3 + a3,
m.a4 + a4,
m.b1 + b1,
m.b2 + b2,
m.b3 + b3,
m.b4 + b4,
m.c1 + c1,
m.c2 + c2,
m.c3 + c3,
m.c4 + c4,
m.d1 + d1,
m.d2 + d2,
m.d3 + d3,
m.d4 + d4);
return temp;
}
// ----------------------------------------------------------------------------------------
template <typename TReal>
inline aiMatrix4x4t<TReal> aiMatrix4x4t<TReal>::operator* (const aiMatrix4x4t<TReal>& m) const