* @brief Calculates the left and right eye transformation matrices for 3D anaglyph rendering. */
| 1081 | * @brief Calculates the left and right eye transformation matrices for 3D anaglyph rendering. |
| 1082 | */ |
| 1083 | QPair<QMatrix4x4, QMatrix4x4> Widgets::Plot3D::eyeTransformations(const QMatrix4x4& matrix) |
| 1084 | { |
| 1085 | float shift = m_eyeSeparation / (2.0f) * (m_invertEyePositions ? -1 : 1); |
| 1086 | |
| 1087 | const float distance = 10.0f; |
| 1088 | const float angleRad = std::atan(shift / distance); |
| 1089 | const float angleDeg = angleRad * 180.0f / float(M_PI); |
| 1090 | |
| 1091 | QMatrix4x4 lMatrix = matrix; |
| 1092 | lMatrix.translate(shift, 0.0f, 0.0f); |
| 1093 | lMatrix.rotate(angleDeg, 0, 0, 1); |
| 1094 | |
| 1095 | QMatrix4x4 rMatrix = matrix; |
| 1096 | rMatrix.translate(-shift, 0.0f, 0.0f); |
| 1097 | rMatrix.rotate(-angleDeg, 0, 0, 1); |
| 1098 | |
| 1099 | return qMakePair(lMatrix, rMatrix); |
| 1100 | } |
| 1101 | |
| 1102 | //-------------------------------------------------------------------------------------------------- |
| 1103 | // Input event handling |