comparison OrthancStone/Sources/Scene2D/TextureBaseSceneLayer.cpp @ 1769:a217140dd41a

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 May 2021 10:26:13 +0200
parents 226718777702
children 073484e33bee
comparison
equal deleted inserted replaced
1768:226718777702 1769:a217140dd41a
158 transform_.reset(NULL); 158 transform_.reset(NULL);
159 IncrementRevision(); 159 IncrementRevision();
160 } 160 }
161 161
162 162
163 void TextureBaseSceneLayer::SetCuttingPlaneTransform(const CoordinateSystem3D& cuttingPlane,
164 const Vector& origin,
165 const Vector& pixelOffsetX,
166 const Vector& pixelOffsetY)
167 {
168 double x0, y0, x1, y1, x2, y2;
169 cuttingPlane.ProjectPoint(x0, y0, origin);
170 cuttingPlane.ProjectPoint(x1, y1, origin + pixelOffsetX);
171 cuttingPlane.ProjectPoint(x2, y2, origin + pixelOffsetY);
172
173 /**
174
175 A = [ a11 a12 ; a21 a22 ]
176
177 (1) A * (0 ; 0) + (b1 ; b2) = (x0 ; y0)
178 (2) A * (1 ; 0) + (b1 ; b2) = (x1 ; y1)
179 (3) A * (0 ; 1) + (b1 ; b2) = (x2 ; y2)
180
181 (2-1) A * (1 ; 0) = (x1 - x0 ; y1 - y0) <=> (a11 ; a21) = (x1 - x0 ; y1 - y0)
182 (3-1) A * (0 ; 1) = (x2 - x0 ; y2 - y0) <=> (a12 ; a22) = (x2 - x0 ; y2 - y0)
183
184 **/
185
186 Matrix m(3, 3);
187 m(0, 0) = x1 - x0; // a11
188 m(0, 1) = x2 - x0; // a12
189 m(0, 2) = x0; // b1
190 m(1, 0) = y1 - y0; // a21
191 m(1, 1) = y2 - y0; // a22
192 m(1, 2) = y0; // b2
193 m(2, 0) = 0;
194 m(2, 1) = 0;
195 m(2, 2) = 1;
196
197 SetTransform(AffineTransform2D(m));
198 }
199
200
163 AffineTransform2D TextureBaseSceneLayer::GetTransform() const 201 AffineTransform2D TextureBaseSceneLayer::GetTransform() const
164 { 202 {
165 if (transform_.get() == NULL) 203 if (transform_.get() == NULL)
166 { 204 {
167 unsigned int width = 0; 205 unsigned int width = 0;