| 238 | } |
| 239 | |
| 240 | ScreenBase::MatrixT ScreenBase::CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2, |
| 241 | m2::PointD const & newPt1, m2::PointD const & newPt2, bool allowRotate, |
| 242 | bool allowScale) |
| 243 | { |
| 244 | double const s = allowScale ? newPt1.Length(newPt2) / oldPt1.Length(oldPt2) : 1.0; |
| 245 | double const a = allowRotate ? ang::AngleTo(newPt1, newPt2) - ang::AngleTo(oldPt1, oldPt2) : 0.0; |
| 246 | |
| 247 | MatrixT m = |
| 248 | math::Shift(math::Scale(math::Rotate(math::Shift(math::Identity<double, 3>(), -oldPt1.x, -oldPt1.y), a), s, s), |
| 249 | newPt1.x, newPt1.y); |
| 250 | return m; |
| 251 | } |
| 252 | |
| 253 | void ScreenBase::SetGtoPMatrix(MatrixT const & m) |
| 254 | { |