| 51 | } |
| 52 | |
| 53 | void ScreenBase::UpdateDependentParameters() |
| 54 | { |
| 55 | m_PixelRect = CalculatePixelRect(m_Scale); |
| 56 | |
| 57 | m_PtoG = math::Shift( /// 5. shifting on (E0, N0) |
| 58 | math::Rotate( /// 4. rotating on the screen angle |
| 59 | math::Scale( /// 3. scaling to translate pixel sizes to global |
| 60 | math::Scale( /// 2. swapping the Y axis??? why??? supposed to be a rotation on -pi / |
| 61 | /// 2 here. |
| 62 | math::Shift( /// 1. shifting for the pixel center to become (0, 0) |
| 63 | math::Identity<double, 3>(), -m_PixelRect.Center()), |
| 64 | 1, -1), |
| 65 | m_Scale, m_Scale), |
| 66 | m_Angle.cos(), m_Angle.sin()), |
| 67 | m_Org); |
| 68 | |
| 69 | m_GtoP = math::Inverse(m_PtoG); |
| 70 | |
| 71 | m2::PointD const pxC = m_PixelRect.Center(); |
| 72 | m2::PointD const glbC = PtoG(pxC); |
| 73 | double const szX = PtoG(m2::PointD(m_PixelRect.maxX(), pxC.y)).Length(glbC); |
| 74 | double const szY = PtoG(m2::PointD(pxC.x, m_PixelRect.minY())).Length(glbC); |
| 75 | |
| 76 | m_GlobalRect = m2::AnyRectD(m_Org, m_Angle, m2::RectD(-szX, -szY, szX, szY)); |
| 77 | m_ClipRect = m_GlobalRect.GetGlobalRect(); |
| 78 | |
| 79 | double constexpr kEps = 1.0E-5; |
| 80 | double const angle = CalculatePerspectiveAngle(m_Scale); |
| 81 | m_isPerspective = angle > 0.0; |
| 82 | if (std::fabs(angle - m_3dAngleX) > kEps) |
| 83 | { |
| 84 | m_3dMaxAngleX = angle; |
| 85 | m_3dScale = CalculateScale3d(angle); |
| 86 | SetRotationAngle(angle); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | // static |
| 91 | double ScreenBase::CalculateAutoPerspectiveAngle(double scale) |