| 54 | } |
| 55 | |
| 56 | bool MatrixF::isAffine() const |
| 57 | { |
| 58 | // An affine transform is defined by the following structure |
| 59 | // |
| 60 | // [ X X X P ] |
| 61 | // [ X X X P ] |
| 62 | // [ X X X P ] |
| 63 | // [ 0 0 0 1 ] |
| 64 | // |
| 65 | // Where X is an orthonormal 3x3 submatrix and P is an arbitrary translation |
| 66 | // We'll check in the following order: |
| 67 | // 1: [3][3] must be 1 |
| 68 | // 2: Shear portion must be zero |
| 69 | // 3: Dot products of rows and columns must be zero |
| 70 | // 4: Length of rows and columns must be 1 |
| 71 | // |
| 72 | if (m[idx(3,3)] != 1.0f) |
| 73 | return false; |
| 74 | |
| 75 | if (m[idx(0,3)] != 0.0f || |
| 76 | m[idx(1,3)] != 0.0f || |
| 77 | m[idx(2,3)] != 0.0f) |
| 78 | return false; |
| 79 | |
| 80 | Point3F one, two, three; |
| 81 | getColumn(0, &one); |
| 82 | getColumn(1, &two); |
| 83 | getColumn(2, &three); |
| 84 | if (mDot(one, two) > 0.0001f || |
| 85 | mDot(one, three) > 0.0001f || |
| 86 | mDot(two, three) > 0.0001f) |
| 87 | return false; |
| 88 | |
| 89 | if (mFabs(1.0f - one.lenSquared()) > 0.0001f || |
| 90 | mFabs(1.0f - two.lenSquared()) > 0.0001f || |
| 91 | mFabs(1.0f - three.lenSquared()) > 0.0001f) |
| 92 | return false; |
| 93 | |
| 94 | getRow(0, &one); |
| 95 | getRow(1, &two); |
| 96 | getRow(2, &three); |
| 97 | if (mDot(one, two) > 0.0001f || |
| 98 | mDot(one, three) > 0.0001f || |
| 99 | mDot(two, three) > 0.0001f) |
| 100 | return false; |
| 101 | |
| 102 | if (mFabs(1.0f - one.lenSquared()) > 0.0001f || |
| 103 | mFabs(1.0f - two.lenSquared()) > 0.0001f || |
| 104 | mFabs(1.0f - three.lenSquared()) > 0.0001f) |
| 105 | return false; |
| 106 | |
| 107 | // We're ok. |
| 108 | return true; |
| 109 | } |
| 110 | |
| 111 | // Perform inverse on full 4x4 matrix. Used in special cases only, so not at all optimized. |
| 112 | bool MatrixF::fullInverse() |
no test coverage detected