Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Krita
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tusooa Zhu
Krita
Commits
46b755c4
Commit
46b755c4
authored
Sep 25, 2014
by
Dmitry Kazakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented transformAsBase() function for KisAlgebra2D
parent
000e69ee
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
0 deletions
+79
-0
krita/image/kis_algebra_2d.cpp
krita/image/kis_algebra_2d.cpp
+22
-0
krita/image/kis_algebra_2d.h
krita/image/kis_algebra_2d.h
+8
-0
krita/image/tests/kis_cage_transform_worker_test.cpp
krita/image/tests/kis_cage_transform_worker_test.cpp
+47
-0
krita/image/tests/kis_cage_transform_worker_test.h
krita/image/tests/kis_cage_transform_worker_test.h
+2
-0
No files found.
krita/image/kis_algebra_2d.cpp
View file @
46b755c4
...
...
@@ -55,4 +55,26 @@ void KRITAIMAGE_EXPORT adjustIfOnPolygonBoundary(const QPolygonF &poly, int poly
}
}
QPointF
KRITAIMAGE_EXPORT
transformAsBase
(
const
QPointF
&
pt
,
const
QPointF
&
base1
,
const
QPointF
&
base2
)
{
qreal
len1
=
norm
(
base1
);
if
(
len1
<
1e-5
)
return
pt
;
qreal
sin1
=
base1
.
y
()
/
len1
;
qreal
cos1
=
base1
.
x
()
/
len1
;
qreal
len2
=
norm
(
base2
);
if
(
len2
<
1e-5
)
return
QPointF
();
qreal
sin2
=
base2
.
y
()
/
len2
;
qreal
cos2
=
base2
.
x
()
/
len2
;
qreal
sinD
=
sin2
*
cos1
-
cos2
*
sin1
;
qreal
cosD
=
cos1
*
cos2
+
sin1
*
sin2
;
qreal
scaleD
=
len2
/
len1
;
QPointF
result
;
result
.
rx
()
=
scaleD
*
(
pt
.
x
()
*
cosD
-
pt
.
y
()
*
sinD
);
result
.
ry
()
=
scaleD
*
(
pt
.
x
()
*
sinD
+
pt
.
y
()
*
cosD
);
return
result
;
}
}
krita/image/kis_algebra_2d.h
View file @
46b755c4
...
...
@@ -121,6 +121,14 @@ bool isInRange(T x, T a, T b) {
void
KRITAIMAGE_EXPORT
adjustIfOnPolygonBoundary
(
const
QPolygonF
&
poly
,
int
polygonDirection
,
QPointF
*
pt
);
/**
* Let \p pt, \p base1 are two vectors. \p base1 is uniformly scaled
* and then rotated into \p base2 using transformation matrix S *
* R. The function applies the same transformation to \pt and returns
* the result.
**/
QPointF
transformAsBase
(
const
QPointF
&
pt
,
const
QPointF
&
base1
,
const
QPointF
&
base2
);
}
#endif
/* __KIS_ALGEBRA_2D_H */
krita/image/tests/kis_cage_transform_worker_test.cpp
View file @
46b755c4
...
...
@@ -203,5 +203,52 @@ void KisCageTransformWorkerTest::testUnityGreenCoordinates()
}
}
#include "kis_algebra_2d.h"
void
KisCageTransformWorkerTest
::
testTransformAsBase
()
{
QPointF
t
(
1.0
,
0.0
);
QPointF
b1
(
1.0
,
0.0
);
QPointF
b2
(
2.0
,
0.0
);
QPointF
result
;
t
=
QPointF
(
1.0
,
0.0
);
b1
=
QPointF
(
1.0
,
0.0
);
b2
=
QPointF
(
2.0
,
0.0
);
result
=
KisAlgebra2D
::
transformAsBase
(
t
,
b1
,
b2
);
QCOMPARE
(
result
,
QPointF
(
2.0
,
0.0
));
t
=
QPointF
(
1.0
,
0.0
);
b1
=
QPointF
(
1.0
,
0.0
);
b2
=
QPointF
(
0.0
,
1.0
);
result
=
KisAlgebra2D
::
transformAsBase
(
t
,
b1
,
b2
);
QCOMPARE
(
result
,
QPointF
(
0.0
,
1.0
));
t
=
QPointF
(
1.0
,
0.0
);
b1
=
QPointF
(
1.0
,
0.0
);
b2
=
QPointF
(
0.0
,
2.0
);
result
=
KisAlgebra2D
::
transformAsBase
(
t
,
b1
,
b2
);
QCOMPARE
(
result
,
QPointF
(
0.0
,
2.0
));
t
=
QPointF
(
0.0
,
1.0
);
b1
=
QPointF
(
1.0
,
0.0
);
b2
=
QPointF
(
2.0
,
0.0
);
result
=
KisAlgebra2D
::
transformAsBase
(
t
,
b1
,
b2
);
QCOMPARE
(
result
,
QPointF
(
0.0
,
2.0
));
t
=
QPointF
(
0.0
,
1.0
);
b1
=
QPointF
(
1.0
,
0.0
);
b2
=
QPointF
(
0.0
,
1.0
);
result
=
KisAlgebra2D
::
transformAsBase
(
t
,
b1
,
b2
);
QCOMPARE
(
result
,
QPointF
(
-
1.0
,
0.0
));
t
=
QPointF
(
0.0
,
1.0
);
b1
=
QPointF
(
1.0
,
0.0
);
b2
=
QPointF
(
0.0
,
2.0
);
result
=
KisAlgebra2D
::
transformAsBase
(
t
,
b1
,
b2
);
QCOMPARE
(
result
,
QPointF
(
-
2.0
,
0.0
));
}
QTEST_KDEMAIN
(
KisCageTransformWorkerTest
,
GUI
)
krita/image/tests/kis_cage_transform_worker_test.h
View file @
46b755c4
...
...
@@ -34,6 +34,8 @@ private slots:
void
testCageCounterclockwiseUnity
();
void
testUnityGreenCoordinates
();
void
testTransformAsBase
();
};
#endif
/* __KIS_CAGE_TRANSFORM_WORKER_TEST_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment