MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / eyeTransformations

Method eyeTransformations

app/src/UI/Widgets/Plot3D.cpp:1083–1100  ·  view source on GitHub ↗

* @brief Calculates the left and right eye transformation matrices for 3D anaglyph rendering. */

Source from the content-addressed store, hash-verified

1081 * @brief Calculates the left and right eye transformation matrices for 3D anaglyph rendering.
1082 */
1083QPair<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

Callers

nothing calls this directly

Calls 3

atanFunction · 0.85
translateMethod · 0.80
rotateMethod · 0.45

Tested by

no test coverage detected