Skip to content

Commit

Permalink
Vector2 Constants
Browse files Browse the repository at this point in the history
- `zero()` and `one()` functions changed to const/inline functions
  • Loading branch information
Alex-Velez authored Jan 28, 2022
1 parent 11bb682 commit 3075a9b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions raylib/src/core/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ impl Vector2 {
Vector2 { x, y }
}

/// Returns a new `Vector2` with both components set to zero.
#[inline]
pub const fn zero() -> Vector2 {
Vector2 { x: 0.0, y: 0.0 }
}

/// Returns a new `Vector2` with both components set to one.
#[inline]
pub const fn one() -> Vector2 {
Vector2 { x: 1.0, y: 1.0 }
}

/// Calculates the vector length.
pub fn length(&self) -> f32 {
((self.x * self.x) + (self.y * self.y)).sqrt()
Expand Down

0 comments on commit 3075a9b

Please sign in to comment.