Struct mathf::vector2::Vector2
[−]
[src]
pub struct Vector2 { pub x: f32, pub y: f32, }
A 2D Vector with x and y coordinates: Vector2
Fields
x: f32
y: f32
Methods
impl Vector2
[src]
fn new(x: f32, y: f32) -> Vector2
Instantiates a new vector with to be defined values of x and y;
fn diff(origin: Point2, destination: Point2) -> Vector2
Instantiates a new Vector2 from 2 Point2 (initial position, final position). The new vector is created as final - initial (Points)
fn UP() -> Vector2
Defines a Vector with UP direction (y=1, x=0)
fn DOWN() -> Vector2
Defines a Vector with DOWN direction (y=-1, x=0)
fn RIGHT() -> Vector2
Defines a Vector with RIGHT direction (y=0, x=1)
fn LEFT() -> Vector2
Defines a Vector with LEFT direction (y=0, x=-1)
fn ONE() -> Vector2
Defines a 2D Vector with x=1 and y=1
fn ZERO() -> Vector2
Defines a Modulus ZERO Vector (x=0, y=0)
fn magnitude(self) -> f32
Vector magnitude: the square root of the sum of each vector part to the power of 2
Trait Implementations
impl Clone for Vector2
[src]
fn clone(&self) -> Vector2
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Vector2
[src]
fn eq(&self, __arg_0: &Vector2) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Vector2) -> bool
This method tests for !=
.
impl Debug for Vector2
[src]
impl Add for Vector2
[src]
type Output = Vector2
The resulting type after applying the +
operator
fn add(self, new_vec: Vector2) -> Vector2
Implements the Vector2 '+' trait
impl Mul<f32> for Vector2
[src]
type Output = Vector2
The resulting type after applying the *
operator
fn mul(self, value: f32) -> Vector2
Implements the scalar multiplication of a Vector2 with a f32. Other numbers should be passed with 'i as f32'
impl Mul<Vector2> for Vector2
[src]
type Output = f32
The resulting type after applying the *
operator
fn mul(self, new_vec: Vector2) -> f32
Implements the dot product of 2 Vector2 as '*'.