Merge pull request #128 from corwinkuiper/hadamard

add more maths
This commit is contained in:
Corwin 2021-10-29 19:08:02 +01:00 committed by GitHub
commit 3734d01709
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -720,6 +720,18 @@ impl<T: Number> Vector2D<T> {
pub fn get(self) -> (T, T) {
(self.x, self.y)
}
pub fn hadamard(self, other: Self) -> Self {
Self {
x: self.x * other.x,
y: self.y * other.y,
}
}
pub fn swap(self) -> Self {
Self {
x: self.y,
y: self.x,
}
}
}
#[test_case]