Skip to content

Commit

Permalink
Fixed issue #897.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed May 13, 2022
1 parent 710994f commit 22f4003
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/org/nschmidt/ldparteditor/data/VM23FlatSubfileTester.java
Expand Up @@ -107,23 +107,26 @@ public List<ParsingResult> checkForFlatScaling(GData1 ref) {
}

Matrix tMatrix2 = ref.accurateLocalMatrix;
final BigDecimal lengthX = plainOnX ? MathHelper.sqrt(tMatrix2.m00.multiply(tMatrix2.m00).add(tMatrix2.m01.multiply(tMatrix2.m01)).add(tMatrix2.m02.multiply(tMatrix2.m02))).subtract(BigDecimal.ONE).abs() : null;
final BigDecimal lengthY = plainOnY ? MathHelper.sqrt(tMatrix2.m10.multiply(tMatrix2.m10).add(tMatrix2.m11.multiply(tMatrix2.m11)).add(tMatrix2.m12.multiply(tMatrix2.m12))).subtract(BigDecimal.ONE).abs() : null;
final BigDecimal lengthZ = plainOnZ ? MathHelper.sqrt(tMatrix2.m20.multiply(tMatrix2.m20).add(tMatrix2.m21.multiply(tMatrix2.m21)).add(tMatrix2.m22.multiply(tMatrix2.m22))).subtract(BigDecimal.ONE).abs() : null;
// Epsilon is 0.000001 / DATHeader default value is 0.0005
final BigDecimal epsilon = new BigDecimal("0.000001"); //$NON-NLS-1$
if (plainOnX && epsilon.compareTo(lengthX) < 0) {
result.add(new ParsingResult(I18n.VM_FLAT_SCALED_X, "[W02] " + I18n.DATPARSER_WARNING, ResultType.WARN)); //$NON-NLS-1$
if (plainOnX && plainOnY && plainOnZ) {
result.add(new ParsingResult(I18n.VM_EMPTY_SUBFILE, "[WEF] " + I18n.DATPARSER_WARNING, ResultType.WARN)); //$NON-NLS-1$
} else {
final BigDecimal lengthX = plainOnX ? MathHelper.sqrt(tMatrix2.m00.multiply(tMatrix2.m00).add(tMatrix2.m01.multiply(tMatrix2.m01)).add(tMatrix2.m02.multiply(tMatrix2.m02))).subtract(BigDecimal.ONE).abs() : null;
final BigDecimal lengthZ = plainOnZ ? MathHelper.sqrt(tMatrix2.m20.multiply(tMatrix2.m20).add(tMatrix2.m21.multiply(tMatrix2.m21)).add(tMatrix2.m22.multiply(tMatrix2.m22))).subtract(BigDecimal.ONE).abs() : null;

if (plainOnX && epsilon.compareTo(lengthX) < 0) {
result.add(new ParsingResult(I18n.VM_FLAT_SCALED_X, "[W02] " + I18n.DATPARSER_WARNING, ResultType.WARN)); //$NON-NLS-1$
}
if (plainOnZ && epsilon.compareTo(lengthZ) < 0) {
result.add(new ParsingResult(I18n.VM_FLAT_SCALED_Z, "[W04] " + I18n.DATPARSER_WARNING, ResultType.WARN)); //$NON-NLS-1$
}
}

final BigDecimal lengthY = plainOnY ? MathHelper.sqrt(tMatrix2.m10.multiply(tMatrix2.m10).add(tMatrix2.m11.multiply(tMatrix2.m11)).add(tMatrix2.m12.multiply(tMatrix2.m12))).subtract(BigDecimal.ONE).abs() : null;
if (plainOnY && epsilon.compareTo(lengthY) < 0) {
result.add(new ParsingResult(I18n.VM_FLAT_SCALED_Y, "[W03] " + I18n.DATPARSER_WARNING, ResultType.WARN)); //$NON-NLS-1$
}
if (plainOnZ && epsilon.compareTo(lengthZ) < 0) {
result.add(new ParsingResult(I18n.VM_FLAT_SCALED_Z, "[W04] " + I18n.DATPARSER_WARNING, ResultType.WARN)); //$NON-NLS-1$
}
if (plainOnX && plainOnY && plainOnZ) {
result.add(new ParsingResult(I18n.VM_EMPTY_SUBFILE, "[WEF] " + I18n.DATPARSER_WARNING, ResultType.WARN)); //$NON-NLS-1$
}

return result;
}
Expand Down

0 comments on commit 22f4003

Please sign in to comment.