This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit af019ca1ae6610ffc5de6a52d958a0b878d80cb0
Author: jsorel <[email protected]>
AuthorDate: Fri Nov 27 11:12:29 2026 +0100

    refactor(Math): remove vector overrides identical to the Vector defaults
---
 .../main/org/apache/sis/maths/Vector.java          | 10 ++--
 .../main/org/apache/sis/maths/Vector1D.java        | 33 -------------
 .../main/org/apache/sis/maths/Vector2D.java        | 33 -------------
 .../main/org/apache/sis/maths/Vector3D.java        | 55 ----------------------
 .../main/org/apache/sis/maths/Vector4D.java        | 33 -------------
 .../main/org/apache/sis/maths/VectorND.java        | 33 -------------
 6 files changed, 4 insertions(+), 193 deletions(-)

diff --git 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector.java 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector.java
index f59f6793a7..4741e39b74 100644
--- 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector.java
+++ 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector.java
@@ -657,9 +657,8 @@ public sealed interface Vector<T extends Vector<T>> permits 
AbstractVector {
      * @throws IllegalArgumentException if a vector size is not 3
      */
     default Vector3D.Double cross(Vector<?> other) {
-        if (getDimension() != 3 || other.getDimension() != 3) {
-            throw new IllegalArgumentException("vector and other size must be 
3.");
-        }
+        AbstractVector.ensureDimension(this, 3);
+        AbstractVector.ensureDimension(other, 3);
         final double x = get(0), y = get(1), z = get(2);
         final double ox = other.get(0), oy = other.get(1), oz = other.get(2);
         return Vector.of(
@@ -679,9 +678,8 @@ public sealed interface Vector<T extends Vector<T>> permits 
AbstractVector {
      * @throws IllegalArgumentException if a vector size is not 3
      */
     default Vector3D.Double crossAccurate(Vector<?> other) {
-        if (getDimension() != 3 || other.getDimension() != 3) {
-            throw new IllegalArgumentException("vector and other size must be 
3.");
-        }
+        AbstractVector.ensureDimension(this, 3);
+        AbstractVector.ensureDimension(other, 3);
         final double x = get(0), y = get(1), z = get(2);
         final double ox = other.get(0), oy = other.get(1), oz = other.get(2);
         return Vector.of(
diff --git 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector1D.java 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector1D.java
index 97f1095106..f69a689167 100644
--- 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector1D.java
+++ 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector1D.java
@@ -40,39 +40,6 @@ public abstract sealed class Vector1D<T extends Vector1D<T>> 
extends AbstractVec
         return 1;
     }
 
-    @Override
-    public T normalize() {
-        return scale(1.0 / length());
-    }
-
-    @Override
-    public T negate() {
-        return scale(-1);
-    }
-
-    @Override
-    public T perpendicular(Vector<?> unit) {
-        ensureDimension(unit, 1);
-        return combine(1, unit, -dot(unit));
-    }
-
-    @Override
-    public T lerpAccurate(Vector<?> other, double ratio) {
-        ensureDimension(other, 1);
-        return combineAccurate(1 - ratio, other, ratio);
-    }
-
-    @Override
-    public T slerp(Vector<?> other, double ratio) {
-        return AbstractVector.slerp(this, other, ratio, (a, b) -> combine(a, 
other, b));
-    }
-
-    @Override
-    public T vectorTo(Vector<?> other) {
-        ensureDimension(other, 1);
-        return combine(-1, other, 1);
-    }
-
     @Override
     public double lengthSquare() {
         final double v0 = get(0);
diff --git 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector2D.java 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector2D.java
index 743460bf5a..801bb9117d 100644
--- 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector2D.java
+++ 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector2D.java
@@ -69,39 +69,6 @@ public abstract sealed class Vector2D<T extends Vector2D<T>> 
extends AbstractVec
         return 2;
     }
 
-    @Override
-    public T normalize() {
-        return scale(1.0 / length());
-    }
-
-    @Override
-    public T negate() {
-        return scale(-1);
-    }
-
-    @Override
-    public T perpendicular(Vector<?> unit) {
-        ensureDimension(unit, 2);
-        return combine(1, unit, -dot(unit));
-    }
-
-    @Override
-    public T lerpAccurate(Vector<?> other, double ratio) {
-        ensureDimension(other, 2);
-        return combineAccurate(1 - ratio, other, ratio);
-    }
-
-    @Override
-    public T slerp(Vector<?> other, double ratio) {
-        return AbstractVector.slerp(this, other, ratio, (a, b) -> combine(a, 
other, b));
-    }
-
-    @Override
-    public T vectorTo(Vector<?> other) {
-        ensureDimension(other, 2);
-        return combine(-1, other, 1);
-    }
-
     @Override
     public double lengthSquare() {
         final double v0 = get(0);
diff --git 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector3D.java 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector3D.java
index b533d3fa89..9aacf86e52 100644
--- 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector3D.java
+++ 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector3D.java
@@ -143,39 +143,6 @@ public abstract sealed class Vector3D<T extends 
Vector3D<T>> extends AbstractVec
         return 3;
     }
 
-    @Override
-    public T normalize() {
-        return scale(1.0 / length());
-    }
-
-    @Override
-    public T negate() {
-        return scale(-1);
-    }
-
-    @Override
-    public T perpendicular(Vector<?> unit) {
-        ensureDimension(unit, 3);
-        return combine(1, unit, -dot(unit));
-    }
-
-    @Override
-    public T lerpAccurate(Vector<?> other, double ratio) {
-        ensureDimension(other, 3);
-        return combineAccurate(1 - ratio, other, ratio);
-    }
-
-    @Override
-    public T slerp(Vector<?> other, double ratio) {
-        return AbstractVector.slerp(this, other, ratio, (a, b) -> combine(a, 
other, b));
-    }
-
-    @Override
-    public T vectorTo(Vector<?> other) {
-        ensureDimension(other, 3);
-        return combine(-1, other, 1);
-    }
-
     @Override
     public double lengthSquare() {
         final double v0 = get(0);
@@ -207,28 +174,6 @@ public abstract sealed class Vector3D<T extends 
Vector3D<T>> extends AbstractVec
         return d0*d0 + d1*d1 + d2*d2;
     }
 
-    @Override
-    public Vector3D.Double cross(Vector<?> other) {
-        ensureDimension(other, 3);
-        final double x = get(0), y = get(1), z = get(2);
-        final double ox = other.get(0), oy = other.get(1), oz = other.get(2);
-        return Vector.of(
-                (y * oz) - (z * oy),
-                (z * ox) - (x * oz),
-                (x * oy) - (y * ox));
-    }
-
-    @Override
-    public Vector3D.Double crossAccurate(Vector<?> other) {
-        ensureDimension(other, 3);
-        final double x = get(0), y = get(1), z = get(2);
-        final double ox = other.get(0), oy = other.get(1), oz = other.get(2);
-        return Vector.of(
-                LinearCombination.of(y, oz, -z, oy),
-                LinearCombination.of(z, ox, -x, oz),
-                LinearCombination.of(x, oy, -y, ox));
-    }
-
     public static final class Byte extends Vector3D<Byte> {
 
         public final byte x;
diff --git 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector4D.java 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector4D.java
index 39ba1d9417..9148ad2ae5 100644
--- 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector4D.java
+++ 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/Vector4D.java
@@ -40,39 +40,6 @@ public abstract sealed class Vector4D<T extends Vector4D<T>> 
extends AbstractVec
         return 4;
     }
 
-    @Override
-    public T normalize() {
-        return scale(1.0 / length());
-    }
-
-    @Override
-    public T negate() {
-        return scale(-1);
-    }
-
-    @Override
-    public T perpendicular(Vector<?> unit) {
-        ensureDimension(unit, 4);
-        return combine(1, unit, -dot(unit));
-    }
-
-    @Override
-    public T lerpAccurate(Vector<?> other, double ratio) {
-        ensureDimension(other, 4);
-        return combineAccurate(1 - ratio, other, ratio);
-    }
-
-    @Override
-    public T slerp(Vector<?> other, double ratio) {
-        return AbstractVector.slerp(this, other, ratio, (a, b) -> combine(a, 
other, b));
-    }
-
-    @Override
-    public T vectorTo(Vector<?> other) {
-        ensureDimension(other, 4);
-        return combine(-1, other, 1);
-    }
-
     @Override
     public double lengthSquare() {
         final double v0 = get(0);
diff --git 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/VectorND.java 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/VectorND.java
index c0eed22d2c..e616aab961 100644
--- 
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/VectorND.java
+++ 
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/maths/VectorND.java
@@ -35,39 +35,6 @@ public abstract sealed class VectorND<T extends VectorND<T>> 
extends AbstractVec
     public VectorND() {
     }
 
-    @Override
-    public T normalize() {
-        return scale(1.0 / length());
-    }
-
-    @Override
-    public T negate() {
-        return scale(-1);
-    }
-
-    @Override
-    public T perpendicular(Vector<?> unit) {
-        ensureDimension(unit, getDimension());
-        return combine(1, unit, -dot(unit));
-    }
-
-    @Override
-    public T lerpAccurate(Vector<?> other, double ratio) {
-        ensureDimension(other, getDimension());
-        return combineAccurate(1 - ratio, other, ratio);
-    }
-
-    @Override
-    public T slerp(Vector<?> other, double ratio) {
-        return AbstractVector.slerp(this, other, ratio, (a, b) -> combine(a, 
other, b));
-    }
-
-    @Override
-    public T vectorTo(Vector<?> other) {
-        ensureDimension(other, getDimension());
-        return combine(-1, other, 1);
-    }
-
     public static final class Byte extends VectorND<Byte> {
 
         private final byte[] values;

Reply via email to