Skip to content

Commit

Permalink
Added individual component getters again.
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaticWyrm467 committed Jun 8, 2024
1 parent 390ccc1 commit aef3034
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/vector/v2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@ impl <T: Scalar> Vec2<T> {
Vec2(T::zero(), self[Y])
}

/// Gets the x component.
pub fn x(&self) -> T {
self.0
}

/// Gets the y component.
pub fn y(&self) -> T {
self.1
}

/// Gets the x and y components of this `Vec2` as another identity function.
pub fn xy(&self) -> Vec2<T> {
self.identity()
Expand Down
15 changes: 15 additions & 0 deletions src/vector/v3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,21 @@ impl <T: Scalar> Vec3<T> {
Vec3(T::zero(), T::zero(), self[Y])
}

/// Gets the x component.
pub fn x(&self) -> T {
self.0
}

/// Gets the y component.
pub fn y(&self) -> T {
self.1
}

/// Gets the z component.
pub fn z(&self) -> T {
self.2
}

/// Gets the x and y compontnets of this `Vec3` as a `Vec2`.
pub fn xy(&self) -> Vec2<T> {
Vec2(self[X], self[Y])
Expand Down

0 comments on commit aef3034

Please sign in to comment.