Struct rusty_sword_arena::game::Vector2 [−][src]
2D Vector (x, y) that can represent coordinates in OpenGL space that fill your window, or velocity, or whatever other two f32 values you need. The OpenGL window is (-1.0, -1.0) in the bottom left to (1.0, 1.0) in the top right.
Fields
x: f32
y: f32
Methods
impl Vector2
[src]
impl Vector2
pub fn new() -> Self
[src]
pub fn new() -> Self
New Vector2D at (0.0, 0.0)
pub fn new_in_square<T: Rng>(dimension: f32, rng: &mut T) -> Self
[src]
pub fn new_in_square<T: Rng>(dimension: f32, rng: &mut T) -> Self
Create a random Vector2D with x and y both in [-dimension, dimension]
pub fn distance_between(&self, other: Self) -> f32
[src]
pub fn distance_between(&self, other: Self) -> f32
Calculate the distance between two Vector2's -- useful when they represent coordinates
pub fn angle_between(&self, other: Self) -> f32
[src]
pub fn angle_between(&self, other: Self) -> f32
Calculate the angle between two Vector2's -- useful when they represent coordinates
pub fn magnitude(&self) -> f32
[src]
pub fn magnitude(&self) -> f32
Calculate the magnitude of the Vector2 -- useful when it represents a vector (such as velocity)
pub fn normalized(&self) -> Self
[src]
pub fn normalized(&self) -> Self
Create a new Vector2D, normalized to be of unit length (length 1).
pub fn clamped_to_normal(&self) -> Self
[src]
pub fn clamped_to_normal(&self) -> Self
Create a new Vector2D that is clamped to a magnitude of 1.0
pub fn clamped_to(&self, magnitude: f32) -> Self
[src]
pub fn clamped_to(&self, magnitude: f32) -> Self
Create a new Vector2D clamped to magnitude
Trait Implementations
impl Copy for Vector2
[src]
impl Copy for Vector2
impl Clone for Vector2
[src]
impl Clone for Vector2
fn clone(&self) -> Vector2
[src]
fn clone(&self) -> Vector2
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Vector2
[src]
impl Debug for Vector2
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for Vector2
[src]
impl PartialEq for Vector2
fn eq(&self, other: &Vector2) -> bool
[src]
fn eq(&self, other: &Vector2) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Vector2) -> bool
[src]
fn ne(&self, other: &Vector2) -> bool
This method tests for !=
.
impl PartialOrd for Vector2
[src]
impl PartialOrd for Vector2
Do docs for trait impls show up???
fn partial_cmp(&self, other: &Vector2) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Vector2) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Add for Vector2
[src]
impl Add for Vector2
type Output = Vector2
The resulting type after applying the +
operator.
fn add(self, other: Vector2) -> Vector2
[src]
fn add(self, other: Vector2) -> Vector2
Performs the +
operation.
impl Mul<f32> for Vector2
[src]
impl Mul<f32> for Vector2