LDPartEditor uses arbitrary precision with an exact epsilon value of 0.000001.
The detection algorithm works for flat files (on the X/Y or Z layer) and is similar to Mike's implementation.
It's nearly the same solution.
I share your opinion.
First, I thought DatHeader had a bug, but DatHeader prefers simply a greater epsilon value...
I strictly recommend not to change the epsilon value to zero. There might be some scenarios which are correct but not numerically stable. It is better to be less cautionous here and prefer a epsilon value greater zero to allow values which are smaller than epsilon.
The detection algorithm works for flat files (on the X/Y or Z layer) and is similar to Mike's implementation.
It's nearly the same solution.
Code:
// M## = Local Matrix (arbitrary precision), Square root with 50+ decimals
final BigDecimal lengthX = Abs(Sqrt(M00 * M00 + M01 * M01 + M02 * M02) - 1);
final BigDecimal lengthY = Abs(Sqrt(M10 * M10 + M11 * M11 + M12 * M12) - 1);
final BigDecimal lengthZ = Abs(Sqrt(M20 * M20 + M21 * M21 + M22 * M22) - 1);
final BigDecimal epsilon = new BigDecimal("0.000001");
if (flatOnX && epsilon.compareTo(lengthX) < 0) {
// Show a warning for X
result.add(new ParsingResult(I18n.VM_FlatScaledX, "[W02] " + I18n.DATPARSER_Warning, ResultType.WARN));
}
if (flatOnY && epsilon.compareTo(lengthY) < 0) {
// Show a warning for Y
result.add(new ParsingResult(I18n.VM_FlatScaledY, "[W03] " ...
}
if (flatOnZ && epsilon.compareTo(lengthZ) < 0) {
// Show a warning for Z
result.add(new ParsingResult(I18n.VM_FlatScaledZ, "[W04] " ...
}
Philippe Hurbain Wrote:As I answered previously, I think checking for scaled flat primitives is a waste of time: I can see no benefit of checking this... Except for the code size, eg. 1 is two character less than 100, but that's pretty useless.
Of course DH autocorrects this error so penalty for parts author is limited too (except for the increased DH execution time).
I share your opinion.
First, I thought DatHeader had a bug, but DatHeader prefers simply a greater epsilon value...
I strictly recommend not to change the epsilon value to zero. There might be some scenarios which are correct but not numerically stable. It is better to be less cautionous here and prefer a epsilon value greater zero to allow values which are smaller than epsilon.