Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

+114
View File
@@ -0,0 +1,114 @@
/**
**
** @RDE_HEADER@
** Implementation of 2d matrix operations
** $Id$
** $HeadURL$
** $Author$
**
** -----------------------------------------------------------------------------------------------
**
** Hardware-Environment: Intel-PC
** Software-Environment: Windows 7, Qt 5.4. ArcGIS 10.2.5
**
** Language ........: C++ 11
**
** -----------------------------------------------------------------------------------------------
**
** Author ...........: Jörg Turla, SPD G, Tel. 3132
**
** -----------------------------------------------------------------------------------------------
**
** Notes .........:
**
** 22.06.2016, JT : First edition for use with Qt5
**
** -----------------------------------------------------------------------------------------------
*/
#include "matrix2d.h"
#include <sstream>
namespace SituationMap { namespace MathUtils
{
QPointF Matrix2D::apply( const QPointF & v ) const
{
QGenericMatrix<1,3,qreal> vM;
vM(0,0) = v.x();
vM(1,0) = v.y();
vM(2,0) = 1.0;
QGenericMatrix<1,3,qreal> result = m_matrix * vM;
qreal x = result(0,0) / result(2,0);
qreal y = result(1,0) / result(2,0);
return QPointF(x,y);
} /* Matrix2D::apply */
void Matrix2D::putTranslation( const QPointF & t )
{
QGenericMatrix<3,3,qreal> tM;
tM(0,2) = t.x();
tM(1,2) = t.y();
m_matrix = tM * m_matrix;
} /* Matrix2D::putTranslation */
void Matrix2D::putScale( const QPointF & s)
{
QGenericMatrix<3,3,qreal> sM;
sM(0,0) = s.x();
sM(1,1) = s.y();
m_matrix = sM * m_matrix;
} /* Matrix2D::putScale */
void Matrix2D::putScale( const QPointF & s, qreal sinPhi, qreal cosPhi )
{
putRotate(QPointF(cosPhi,-sinPhi));
putScale(s);
putRotate(sinPhi,cosPhi);
} /* Matrix2D::putScale */
void Matrix2D::putRotate( qreal sinPhi, qreal cosPhi )
{
QGenericMatrix<3,3,qreal> rM;
rM(0,0) = cosPhi;
rM(0,1) = sinPhi;
rM(1,0) = -sinPhi;
rM(1,1) = cosPhi;
m_matrix = rM * m_matrix;
} /* Matrix2D::putRotate */
std::ostream & operator<< ( std::ostream & stream, const Matrix2D & mat )
{
stream << "Matrix2D:" << std::endl;
for (int r = 0; r < 3; ++r)
{
for (int c = 0; c < 3; ++c)
{
stream << "[" << r << "," << c << "] = " << mat(r,c) << " ";
}
stream << std::endl;
}
return stream;
} // std::ostream & operator<< ( std::ostream & stream, const Matrix2D & mat )
} } // namespace SituationMap::MathUtils