[wpimath] Make Vector-Vector binary operators return Vector (#5772)

Fixes #5741.
This commit is contained in:
Tyler Veness
2023-10-17 16:44:30 -07:00
committed by GitHub
parent ed93889e17
commit 02cbbc997d
2 changed files with 59 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.math;
import edu.wpi.first.math.numbers.N1;
import java.util.Objects;
import org.ejml.simple.SimpleMatrix;
/**
@@ -62,6 +63,26 @@ public class Vector<R extends Num> extends Matrix<R, N1> {
return new Vector<>(this.m_storage.divide(value));
}
/**
* Adds the given vector to this vector.
*
* @param value The vector to add.
* @return The resultant vector.
*/
public final Vector<R> plus(Vector<R> value) {
return new Vector<>(this.m_storage.plus(Objects.requireNonNull(value).m_storage));
}
/**
* Subtracts the given vector to this vector.
*
* @param value The vector to add.
* @return The resultant vector.
*/
public final Vector<R> minus(Vector<R> value) {
return new Vector<>(this.m_storage.minus(Objects.requireNonNull(value).m_storage));
}
/**
* Returns the dot product of this vector with another.
*