annotate Framework/Toolbox/AffineTransform2D.cpp @ 448:cc47e6eaefb0 bgo-commands-codegen

Fixed dummy change
author bgo-osimis
date Wed, 16 Jan 2019 21:08:38 +0100
parents b70e9be013e4
children 911297a277c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
409
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 409
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
409
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "AffineTransform2D.h"
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "ImageGeometry.h"
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include <Core/Logging.h>
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include <Core/OrthancException.h>
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace OrthancStone
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 AffineTransform2D::AffineTransform2D() :
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 matrix_(LinearAlgebra::IdentityMatrix(3))
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 AffineTransform2D::AffineTransform2D(const Matrix& m)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 if (m.size1() != 3 ||
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 m.size2() != 3)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 if (!LinearAlgebra::IsCloseToZero(m(2, 0)) ||
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 !LinearAlgebra::IsCloseToZero(m(2, 1)) ||
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 LinearAlgebra::IsCloseToZero(m(2, 2)))
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 LOG(ERROR) << "Cannot setup an AffineTransform2D with perspective effects";
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 matrix_ = m / m(2, 2);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 void AffineTransform2D::Apply(double& x /* inout */,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 double& y /* inout */) const
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 Vector p;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 LinearAlgebra::AssignVector(p, x, y, 1);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 Vector q = LinearAlgebra::Product(matrix_, p);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 if (!LinearAlgebra::IsNear(q[2], 1.0))
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 else
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 x = q[0];
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 y = q[1];
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 void AffineTransform2D::Apply(Orthanc::ImageAccessor& target,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 const Orthanc::ImageAccessor& source,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 ImageInterpolation interpolation,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 bool clear) const
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 assert(LinearAlgebra::IsNear(matrix_(2, 0), 0) &&
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 LinearAlgebra::IsNear(matrix_(2, 1), 0) &&
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 LinearAlgebra::IsNear(matrix_(2, 2), 1));
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 ApplyAffineTransform(target, source,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 matrix_(0, 0), matrix_(0, 1), matrix_(0, 2),
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 matrix_(1, 0), matrix_(1, 1), matrix_(1, 2),
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 interpolation, clear);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 AffineTransform2D AffineTransform2D::Invert(const AffineTransform2D& a)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 AffineTransform2D t;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 LinearAlgebra::InvertMatrix(t.matrix_, a.matrix_);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 return t;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 AffineTransform2D AffineTransform2D::Combine(const AffineTransform2D& a,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 const AffineTransform2D& b)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 return AffineTransform2D(LinearAlgebra::Product(a.GetHomogeneousMatrix(),
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 b.GetHomogeneousMatrix()));
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 AffineTransform2D AffineTransform2D::Combine(const AffineTransform2D& a,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 const AffineTransform2D& b,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 const AffineTransform2D& c)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 return AffineTransform2D(LinearAlgebra::Product(a.GetHomogeneousMatrix(),
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 b.GetHomogeneousMatrix(),
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 c.GetHomogeneousMatrix()));
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 AffineTransform2D AffineTransform2D::Combine(const AffineTransform2D& a,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 const AffineTransform2D& b,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 const AffineTransform2D& c,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 const AffineTransform2D& d)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 return AffineTransform2D(LinearAlgebra::Product(a.GetHomogeneousMatrix(),
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 b.GetHomogeneousMatrix(),
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 c.GetHomogeneousMatrix(),
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 d.GetHomogeneousMatrix()));
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 AffineTransform2D AffineTransform2D::CreateOffset(double dx,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 double dy)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 AffineTransform2D t;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 t.matrix_(0, 2) = dx;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 t.matrix_(1, 2) = dy;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 return t;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 AffineTransform2D AffineTransform2D::CreateScaling(double sx,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 double sy)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 AffineTransform2D t;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 t.matrix_(0, 0) = sx;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 t.matrix_(1, 1) = sy;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 return t;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 AffineTransform2D AffineTransform2D::CreateRotation(double angle)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 double cosine = cos(angle);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 double sine = sin(angle);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 AffineTransform2D t;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 t.matrix_(0, 0) = cosine;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 t.matrix_(0, 1) = -sine;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 t.matrix_(1, 0) = sine;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 t.matrix_(1, 1) = cosine;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 return t;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }