Inv returns the matrix inverse.
()
| 728 | |
| 729 | // Inv returns the matrix inverse. |
| 730 | func (m Matrix) Inv() Matrix { |
| 731 | det := m.Det() |
| 732 | if Equal(det, 0.0) { |
| 733 | panic("determinant of affine transformation matrix is zero") |
| 734 | } |
| 735 | return Matrix{{ |
| 736 | m[1][1] / det, |
| 737 | -m[0][1] / det, |
| 738 | -(m[1][1]*m[0][2] - m[0][1]*m[1][2]) / det, |
| 739 | }, { |
| 740 | -m[1][0] / det, |
| 741 | m[0][0] / det, |
| 742 | -(-m[1][0]*m[0][2] + m[0][0]*m[1][2]) / det, |
| 743 | }} |
| 744 | } |
| 745 | |
| 746 | // Eigen returns the matrix eigenvalues and eigenvectors. The first eigenvalue is related to the first eigenvector, and so for the second pair. Eigenvectors are normalized. |
| 747 | func (m Matrix) Eigen() (float64, float64, Point, Point) { |