This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 846d83107fa95d78a8541bb2da46134ef4e57b73 Author: Martin Desruisseaux <[email protected]> AuthorDate: Tue Jan 6 11:43:57 2026 +0100 When transforming a 0 coordinate, we need to get the origin even if the scale factor is NaN. --- .../internal/shared/ExtendedPrecisionMatrix.java | 2 +- .../operation/transform/ProjectiveTransform.java | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/ExtendedPrecisionMatrix.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/ExtendedPrecisionMatrix.java index ed1d2d72fb..f93722a684 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/ExtendedPrecisionMatrix.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/shared/ExtendedPrecisionMatrix.java @@ -59,7 +59,7 @@ public interface ExtendedPrecisionMatrix extends Matrix { * The returned matrix should be assumed read-only. * * @param m the matrix to cast or wrap. - * @eturn an extended-precision view of the matrix. + * @return an extended-precision view of the matrix. * * @see org.apache.sis.referencing.operation.matrix.MatrixSIS#asExtendedPrecision(Matrix) */ diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java index ab934631d7..d0cdbbc30b 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java @@ -158,7 +158,7 @@ class ProjectiveTransform extends AbstractLinearTransform implements ExtendedPre for (int i=lower; i<upper; i++) { final Number element = numbers[i]; if (element instanceof Fraction) { - final Fraction f = (Fraction) element; + final var f = (Fraction) element; sum = (sum != null) ? sum.add(f) : f; } } @@ -414,8 +414,13 @@ class ProjectiveTransform extends AbstractLinearTransform implements ExtendedPre * This occurs when the ProjectiveTransform is used for excluding some dimensions, for example * getting 2D points from 3D points. In such case, the fact that the excluded dimensions had * NaN values should not force the retained dimensions to get NaN values. + * + * TODO: we should suppress all the checks for zero values when we are sure that the matrix + * does not contain any NaN value. We will do that after we can use the vector API, which + * would be used when there is no NaN and this Java code used as a fallback when there are NaN. */ - sum = Math.fma(srcPts[srcOff + i], e, sum); + final double c = srcPts[srcOff + i]; + if (c != 0) sum = Math.fma(c, e, sum); } } buffer[j] = sum; @@ -482,7 +487,8 @@ class ProjectiveTransform extends AbstractLinearTransform implements ExtendedPre for (int i=0; i<srcDim; i++) { final double e = elt[mix++]; if (e != 0) { // See comment in transform(double[], ...) - sum = Math.fma(srcPts[srcOff + i], e, sum); + final float c = srcPts[srcOff + i]; + if (c != 0) sum = Math.fma(c, e, sum); } } buffer[j] = sum; @@ -521,7 +527,8 @@ class ProjectiveTransform extends AbstractLinearTransform implements ExtendedPre for (int i=0; i<srcDim; i++) { final double e = elt[mix++]; if (e != 0) { // See comment in transform(double[], ...) - sum = Math.fma(srcPts[srcOff + i], e, sum); + final double c = srcPts[srcOff + i]; + if (c != 0) sum = Math.fma(c, e, sum); } } buffer[j] = sum; @@ -559,7 +566,8 @@ class ProjectiveTransform extends AbstractLinearTransform implements ExtendedPre for (int i=0; i<srcDim; i++) { final double e = elt[mix++]; if (e != 0) { // See comment in transform(double[], ...) - sum = Math.fma(srcPts[srcOff + i], e, sum); + final float c = srcPts[srcOff + i]; + if (c != 0) sum = Math.fma(c, e, sum); } } buffer[j] = sum;
