mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] Make Vector-Vector binary operators return Vector (#5772)
Fixes #5741.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user