Matrix2d Utils::getS(QList<Line*> firstOrtoghonalLines, QList<Line*> secondOrthogonalLines) { Matrix2d S; Vector3d l1 = getLineInHomogeneousCoordinates(firstOrtoghonalLines.at(0)); Vector3d m1 = getLineInHomogeneousCoordinates(firstOrtoghonalLines.at(1)); Vector3d l2 = getLineInHomogeneousCoordinates(secondOrthogonalLines.at(0)); Vector3d m2 = getLineInHomogeneousCoordinates(secondOrthogonalLines.at(1)); // A * x = b. Matrix2d A; MatrixXd B(2,1); A << l1(0)*m1(0), l1(0)*m1(1)+l1(1)*m1(0), l2(0)*m2(0), l2(0)*m2(1)+l2(1)*m2(0); B << -l1(1)*m1(1), -l2(1)*m2(1); MatrixXd x = A.fullPivLu().solve(B); S << x(0,0), x(1,0), x(1,0), 1; return S; }