Skip to content

Commit

Permalink
Impl Neg for IVecN (#134)
Browse files Browse the repository at this point in the history
* Impl Neg for IVecN

* Inline Neg functions for IVecN
  • Loading branch information
SnootierMoon authored Jul 20, 2021
1 parent 9ba47d0 commit 4e7ff46
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

<!-- next-header -->
## Unreleased

- Add methods to scale `Rotor3`
- Implement `Neg` for all `IVec` types

## 0.8.1

Expand Down
39 changes: 39 additions & 0 deletions src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,45 @@ macro_rules! ivec4s {
}
}

impl Neg for IVec2 {
type Output = Self;

#[inline]
fn neg(self) -> Self::Output {
Self {
x: -self.x,
y: -self.y,
}
}
}

impl Neg for IVec3 {
type Output = Self;

#[inline]
fn neg(self) -> Self::Output {
Self {
x: -self.x,
y: -self.y,
z: -self.z,
}
}
}

impl Neg for IVec4 {
type Output = Self;

#[inline]
fn neg(self) -> Self::Output {
Self {
x: -self.x,
y: -self.y,
z: -self.z,
w: -self.w,
}
}
}

impl From<UVec3> for UVec2 {
#[inline]
fn from(vec: UVec3) -> Self {
Expand Down

0 comments on commit 4e7ff46

Please sign in to comment.