Struct matriarch::Vec2 [−][src]
A 2D Vector with elements x and y
Fields
x: f32
y: f32
Methods
impl Vec2
[src]
impl Vec2
pub fn new() -> Vec2
[src]
pub fn new() -> Vec2
Returns a new Vec2 at [0, 0].
Example:
let vec2 = Vec2::new();
pub fn new_from_values(x: &f32, y: &f32) -> Vec2
[src]
pub fn new_from_values(x: &f32, y: &f32) -> Vec2
Returns a new Vec2 using the given values for x and y.
Example:
let x: f32 = 1.0; let y: f32 = 2.0; let vec2 = Vec2::new_from_values(&x, &y);
pub fn new_from_array(input: &[f32; 2]) -> Vec2
[src]
pub fn new_from_array(input: &[f32; 2]) -> Vec2
Returns a new Vec2 using the 0 and 1 indices of the given array, where [0] -> x, and [1] -> y.
Example:
let input = [ 1.0, 2.0 ]; let vec2 = Vec2::new_from_array(&input);
pub fn to_array(&self) -> [f32; 2]
[src]
pub fn to_array(&self) -> [f32; 2]
Returns an array of the Vec2's x and y values where x -> [0], y -> [1].
Example:
let array = some_vec2.to_array();
pub fn cross_product(&self, other_vec2: &Vec2) -> Vec3
[src]
pub fn cross_product(&self, other_vec2: &Vec2) -> Vec3
Returns the cross product of 2 Vec2s as if they were Vec3s with a z component of 0.
We technically can't actually cross-multiply 2 vectors in ℝ², however we can add a z component of 0 and pretend the vectors are in ℝ³ instead, which is why we get a Vec3 at the end.
Example:
use matriarch::Vec3; let vec3: Vec3 = some_vec2.cross_product(&some_other_vec2);
pub fn length(&self) -> f32
[src]
pub fn length(&self) -> f32
Returns the length of the Vec2.
Trait Implementations
impl Mul<Vec2> for Mat2
[src]
impl Mul<Vec2> for Mat2
type Output = Vec2
The resulting type after applying the *
operator.
fn mul(self, vec2: Vec2) -> Vec2
[src]
fn mul(self, vec2: Vec2) -> Vec2
Multiplies a Mat2 by a Vec2, returning a Vec2.
impl Clone for Vec2
[src]
impl Clone for Vec2
fn clone(&self) -> Vec2
[src]
fn clone(&self) -> Vec2
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 Copy for Vec2
[src]
impl Copy for Vec2
impl Debug for Vec2
[src]
impl Debug for Vec2
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 Default for Vec2
[src]
impl Default for Vec2
impl PartialEq for Vec2
[src]
impl PartialEq for Vec2
fn eq(&self, other: &Vec2) -> bool
[src]
fn eq(&self, other: &Vec2) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Vec2) -> bool
[src]
fn ne(&self, other: &Vec2) -> bool
This method tests for !=
.
impl Add<Vec2> for Vec2
[src]
impl Add<Vec2> for Vec2
type Output = Vec2
The resulting type after applying the +
operator.
fn add(self, other_vec2: Vec2) -> Vec2
[src]
fn add(self, other_vec2: Vec2) -> Vec2
Adds one Vec2 to another Vec2 and returns a new Vec2.
Example:
let vec2 = some_vec2 + some_other_vec2;
impl AddAssign for Vec2
[src]
impl AddAssign for Vec2
fn add_assign(&mut self, other_vec2: Vec2)
[src]
fn add_assign(&mut self, other_vec2: Vec2)
Adds one Vec2 to another Vec2 and re-assigns the first Vec2 to the new Vec2.
Example:
some_vec2 += some_other_vec2;
impl Mul<Vec2> for f32
[src]
impl Mul<Vec2> for f32
type Output = Vec2
The resulting type after applying the *
operator.
fn mul(self, other_vec2: Vec2) -> Vec2
[src]
fn mul(self, other_vec2: Vec2) -> Vec2
Multiplies a scalar value by a Vec2 and returns a Vec2.
Example:
let scaled_vec2: Vec2 = some_scalar * some_vec2;
impl Mul<Vec2> for Vec2
[src]
impl Mul<Vec2> for Vec2
type Output = f32
The resulting type after applying the *
operator.
fn mul(self, other_vec2: Vec2) -> f32
[src]
fn mul(self, other_vec2: Vec2) -> f32
Returns the dot product of 2 Vec2s, which is a scalar floating point.
Example:
let scalar: f32 = some_vec2 * some_other_vec2;
impl Neg for Vec2
[src]
impl Neg for Vec2
type Output = Vec2
The resulting type after applying the -
operator.
fn neg(self) -> Vec2
[src]
fn neg(self) -> Vec2
Negates the values of Vec2, which in turn negates the Vec2
Example:
let negated_vec2 = -some_vec2;
impl Sub<Vec2> for Vec2
[src]
impl Sub<Vec2> for Vec2
type Output = Vec2
The resulting type after applying the -
operator.
fn sub(self, other_vec2: Vec2) -> Vec2
[src]
fn sub(self, other_vec2: Vec2) -> Vec2
Subtracts one Vec2 from another Vec2 and returns a new Vec2.
Example:
let vec2 = some_vec2 - some_other_vec2;
impl SubAssign for Vec2
[src]
impl SubAssign for Vec2
fn sub_assign(&mut self, other_vec2: Vec2)
[src]
fn sub_assign(&mut self, other_vec2: Vec2)
Subtracts one Vec2 from another Vec2 and re-assigns the first Vec2 to the new Vec2.
Example:
some_vec2 -= some_other_vec2;