mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-03-20 12:14:45 +01:00
Fixed some bugs.
This commit is contained in:
parent
466cc98536
commit
b161ad781a
|
|
@ -98,48 +98,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDire
|
|||
#ifdef _DEBUG
|
||||
printf("Matrix Determinant: %f\n", det);
|
||||
printf("Matrix Determinant - 1 = %f\n", det -1);
|
||||
printf("FLOATING POINT ERROR: %f\n", FLOATING_POINT_ERROR);
|
||||
#endif
|
||||
|
||||
// use approxEqual to avoid direct comparisons
|
||||
if (approxEqual(det, 1.0f) ||
|
||||
approxEqual(det, -1.0f))
|
||||
{
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("Matrix is Orthogonal\n");
|
||||
#endif
|
||||
/* this matrix is orthogonal
|
||||
|
||||
since inv(M) * M = I
|
||||
when orthogonal
|
||||
trans(M) * M = I
|
||||
|
||||
proper orthogonal
|
||||
inv(M) = trans(M)
|
||||
improper orthogonal
|
||||
inv(M) = -trans(M)
|
||||
*/
|
||||
|
||||
if (approxEqual(det, 1))
|
||||
{
|
||||
// proper orthogonal
|
||||
int srcIndex = 0;
|
||||
for (int col = 0; col < source.width; col++)
|
||||
for (int row = 0; row < source.height; row++)
|
||||
destMatrix[col + row * source.width] = srcMatrix[srcIndex++];
|
||||
}
|
||||
else
|
||||
{
|
||||
// improper orthogonal
|
||||
int srcIndex = 0;
|
||||
for (int col = 0; col < source.width; col++)
|
||||
for (int row = 0; row < source.height; row++)
|
||||
destMatrix[col + row * source.width] = -srcMatrix[srcIndex++];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
float sign;
|
||||
|
||||
|
|
@ -167,12 +126,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpDire
|
|||
= (sign / det) * determinant(temp_matrix, temp_side);
|
||||
|
||||
// swap signs
|
||||
sign = (sign == 1) ? -1.0f : 1.0f;
|
||||
sign *= -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
dest.writeComplete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,49 +98,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe
|
|||
#ifdef _DEBUG
|
||||
printf("Matrix Determinant: %f\n", det);
|
||||
printf("Matrix Determinant - 1: %f\n", det-1);
|
||||
printf("FLOATING POINT ERROR: %f\n", FLOATING_POINT_ERROR);
|
||||
#endif
|
||||
|
||||
// use approxEqual to avoid direct comparisons
|
||||
if (approxEqual(det,1) || approxEqual(det, -1))
|
||||
{
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("Matrix is Orthogonal\n");
|
||||
#endif
|
||||
/* this matrix is orthogonal
|
||||
|
||||
since inv(M) * M = I
|
||||
when orthogonal
|
||||
trans(M) * M = I
|
||||
|
||||
proper orthogonal
|
||||
inv(M) = trans(M)
|
||||
improper orthogonal
|
||||
inv(M) = -trans(M)
|
||||
*/
|
||||
|
||||
if (approxEqual(det, 1))
|
||||
{
|
||||
// proper orthogonal
|
||||
int srcIndex = 0;
|
||||
for (int col = 0; col < source.width; col++)
|
||||
for (int row = 0; row < source.height; row++)
|
||||
destMatrix[col + row * source.width] = srcMatrix[srcIndex++];
|
||||
}
|
||||
else
|
||||
{
|
||||
// improper orthogonal
|
||||
int srcIndex = 0;
|
||||
for (int col = 0; col < source.width; col++)
|
||||
for (int row = 0; row < source.height; row++)
|
||||
destMatrix[col + row * source.width] = -srcMatrix[srcIndex++];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
float sign;
|
||||
float sign;
|
||||
|
||||
for (int col = 0; col < source.width; col++)
|
||||
{
|
||||
|
|
@ -166,11 +126,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpInvert_00024MatrixOpSafe
|
|||
= (sign / det) * determinant(temp_matrix, temp_side);
|
||||
|
||||
// swap signs
|
||||
sign = (sign == 1) ? -1.0f : 1.0f;
|
||||
sign *= -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
dest.writeComplete();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue