Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_perspective_transform_strategy.cpp File Reference
#include "kis_perspective_transform_strategy.h"
#include <QPointF>
#include <QPainter>
#include <QPainterPath>
#include <QMatrix4x4>
#include <QVector2D>
#include <Eigen/Dense>
#include "kis_coordinates_converter.h"
#include "tool_transform_args.h"
#include "transform_transaction_properties.h"
#include "krita_utils.h"
#include "kis_cursor.h"
#include "kis_transform_utils.h"
#include "kis_free_transform_strategy_gsl_helpers.h"

Go to the source code of this file.

Classes

struct  KisPerspectiveTransformStrategy::Private::HandlePoints
 
struct  KisPerspectiveTransformStrategy::Private
 

Functions

QVector4D fromQPointF (const QPointF &pt)
 
Eigen::Matrix3f fromQTransform (const QTransform &t)
 
Eigen::Matrix3f fromScale (qreal sx, qreal sy)
 
Eigen::Matrix3f fromShear (qreal sx, qreal sy)
 
Eigen::Matrix3f fromTranslate (const QPointF &pt)
 
Eigen::Matrix3f getTransitionMatrix (const QVector< QPointF > &sp)
 
QPointF toQPointF (const QVector4D &v)
 
QTransform toQTransform (const Eigen::Matrix3f &m)
 

Function Documentation

◆ fromQPointF()

QVector4D fromQPointF ( const QPointF & pt)

Definition at line 470 of file kis_perspective_transform_strategy.cpp.

470 {
471 return QVector4D(pt.x(), pt.y(), 0, 1.0);
472}

◆ fromQTransform()

Eigen::Matrix3f fromQTransform ( const QTransform & t)

Definition at line 367 of file kis_perspective_transform_strategy.cpp.

368{
369 Eigen::Matrix3f m;
370
371 m << t.m11() , t.m21() , t.m31()
372 ,t.m12() , t.m22() , t.m32()
373 ,t.m13() , t.m23() , t.m33();
374
375 return m;
376}

◆ fromScale()

Eigen::Matrix3f fromScale ( qreal sx,
qreal sy )

Definition at line 389 of file kis_perspective_transform_strategy.cpp.

390{
391 Eigen::Matrix3f m;
392
393 m << sx , 0 , 0
394 ,0 , sy , 0
395 ,0 , 0 , 1;
396
397 return m;
398}

◆ fromShear()

Eigen::Matrix3f fromShear ( qreal sx,
qreal sy )

Definition at line 400 of file kis_perspective_transform_strategy.cpp.

401{
402 Eigen::Matrix3f m;
403
404 m << 1 , sx , 0
405 ,sy , sx*sy + 1, 0
406 ,0 , 0 , 1;
407
408 return m;
409}

◆ fromTranslate()

Eigen::Matrix3f fromTranslate ( const QPointF & pt)

Definition at line 378 of file kis_perspective_transform_strategy.cpp.

379{
380 Eigen::Matrix3f m;
381
382 m << 1 , 0 , pt.x()
383 ,0 , 1 , pt.y()
384 ,0 , 0 , 1;
385
386 return m;
387}

◆ getTransitionMatrix()

Eigen::Matrix3f getTransitionMatrix ( const QVector< QPointF > & sp)

Definition at line 340 of file kis_perspective_transform_strategy.cpp.

341{
342 Eigen::Matrix3f A;
343 Eigen::Vector3f v3;
344
345 A << sp[HANDLE_TOP_LEFT].x() , sp[HANDLE_TOP_RIGHT].x() , sp[HANDLE_BOTTOM_LEFT].x()
346 ,sp[HANDLE_TOP_LEFT].y() , sp[HANDLE_TOP_RIGHT].y() , sp[HANDLE_BOTTOM_LEFT].y()
347 , 1 , 1 , 1;
348
349 v3 << sp[HANDLE_BOTTOM_RIGHT].x() , sp[HANDLE_BOTTOM_RIGHT].y() , 1;
350
351 Eigen::Vector3f coeffs = A.colPivHouseholderQr().solve(v3);
352
353 A.col(0) *= coeffs(0);
354 A.col(1) *= coeffs(1);
355 A.col(2) *= coeffs(2);
356
357 return A;
358}

References A.

◆ toQPointF()

QPointF toQPointF ( const QVector4D & v)

Definition at line 474 of file kis_perspective_transform_strategy.cpp.

474 {
475 return v.toVector2DAffine().toPointF();
476}
qreal v

References v.

◆ toQTransform()

QTransform toQTransform ( const Eigen::Matrix3f & m)

Definition at line 360 of file kis_perspective_transform_strategy.cpp.

361{
362 return QTransform(m(0,0), m(1,0), m(2,0),
363 m(0,1), m(1,1), m(2,1),
364 m(0,2), m(1,2), m(2,2));
365}