Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_perspective_math.h
Go to the documentation of this file.
1/*
2 * This file is part of Krita
3 *
4 * SPDX-FileCopyrightText: 2006 Cyrille Berger <cberger@cberger.net>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef _KIS_PERSPECTIVE_MATH_H_
10#define _KIS_PERSPECTIVE_MATH_H_
11
12#include "kis_vec.h"
13#include <QPointF>
14#include <Eigen/Geometry>
15
16typedef Eigen::Matrix<qreal, 3, 3> Matrix3qreal;
17typedef Eigen::Matrix<qreal, 9, 9> Matrix9qreal;
18typedef Eigen::Matrix<qreal, 9, 1> Vector9qreal;
19typedef Eigen::Hyperplane<qreal, 2> LineEquation;
20
21#include <kritaimage_export.h>
22
23class QRect;
24
25class KRITAIMAGE_EXPORT KisPerspectiveMath
26{
27private:
29public:
30 static Matrix3qreal computeMatrixTransfo(const QPointF& topLeft1, const QPointF& topRight1, const QPointF& bottomLeft1, const QPointF& bottomRight1, const QPointF& topLeft2, const QPointF& topRight2, const QPointF& bottomLeft2, const QPointF& bottomRight2);
31 static Matrix3qreal computeMatrixTransfoToPerspective(const QPointF& topLeft, const QPointF& topRight, const QPointF& bottomLeft, const QPointF& bottomRight, const QRect& r);
32 static Matrix3qreal computeMatrixTransfoFromPerspective(const QRect& r, const QPointF& topLeft, const QPointF& topRight, const QPointF& bottomLeft, const QPointF& bottomRight);
34 static inline QPointF matProd(const Matrix3qreal& m, const QPointF& p) {
35 qreal s = qreal(1) / (p.x() * m.coeff(2, 0) + p.y() * m.coeff(2, 1) + 1.0);
36 return QPointF((p.x() * m.coeff(0, 0) + p.y() * m.coeff(0, 1) + m.coeff(0, 2)) * s,
37 (p.x() * m.coeff(1, 0) + p.y() * m.coeff(1, 1) + m.coeff(1, 2)) * s);
38 }
39};
40
41#endif
const Params2D p
static QPointF matProd(const Matrix3qreal &m, const QPointF &p)
TODO: get rid of this in 2.0.
Eigen::Matrix< qreal, 9, 9 > Matrix9qreal
Eigen::Matrix< qreal, 3, 3 > Matrix3qreal
Eigen::Matrix< qreal, 9, 1 > Vector9qreal
Eigen::Hyperplane< qreal, 2 > LineEquation