Skip to content

Commit

Permalink
Merge pull request #71 from nichollascarter/47-rotating-to-90deg-disa…
Browse files Browse the repository at this point in the history
…bles-rotating-and-resizing

fix(core): fixed issue on rotating to 90deg
  • Loading branch information
nichollascarter authored Oct 3, 2022
2 parents e7cbdc7 + 163e06d commit c5de0be
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/js/core/transform/matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,56 +74,57 @@ export const multiplyMatrix = (m1, m2) => {
};

export const matrixInvert = (matrix) => {
const _A = cloneMatrix(matrix);
const A = cloneMatrix(matrix);
const N = A.length;

let temp,
N = _A.length,
E = [];
let temp, E = [];

for (let i = 0; i < N; i++)
E[i] = [];

for (let i = 0; i < N; i++)
for (let j = 0; j < N; j++) {
E[i][j] = 0;
if (i == j)
if (i === j)
E[i][j] = 1;
}

for (let k = 0; k < N; k++) {
temp = _A[k][k];
temp = A[k][k];

for (let j = 0; j < N; j++) {
_A[k][j] /= temp;
E[k][j] /= temp;
if (temp !== 0) {
for (let j = 0; j < N; j++) {
A[k][j] /= temp;
E[k][j] /= temp;
}
}

for (let i = k + 1; i < N; i++) {
temp = _A[i][k];
temp = A[i][k];

for (let j = 0; j < N; j++) {
_A[i][j] -= _A[k][j] * temp;
A[i][j] -= A[k][j] * temp;
E[i][j] -= E[k][j] * temp;
}
}
}

for (let k = N - 1; k > 0; k--) {
for (let i = k - 1; i >= 0; i--) {
temp = _A[i][k];
temp = A[i][k];

for (let j = 0; j < N; j++) {
_A[i][j] -= _A[k][j] * temp;
A[i][j] -= A[k][j] * temp;
E[i][j] -= E[k][j] * temp;
}
}
}

for (let i = 0; i < N; i++)
for (let j = 0; j < N; j++)
_A[i][j] = E[i][j];
A[i][j] = E[i][j];

return _A;
return A;
};

export const computeTransformMatrix = (tx, [x, y, z]) => {
Expand Down

0 comments on commit c5de0be

Please sign in to comment.