Struct matriarch::Vec2[][src]

pub struct Vec2 {
    pub x: f32,
    pub y: f32,
}

A 2D Vector with elements x and y

Fields

Methods

impl Vec2
[src]

Returns a new Vec2 at [0, 0].

Example:

let vec2 = Vec2::new();

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);

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);

Returns an array of the Vec2's x and y values where x -> [0], y -> [1].

Example:

let array = some_vec2.to_array();

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);

Returns the length of the Vec2.

Trait Implementations

impl Mul<Vec2> for Mat2
[src]

The resulting type after applying the * operator.

Multiplies a Mat2 by a Vec2, returning a Vec2.

impl Clone for Vec2
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Vec2
[src]

impl Debug for Vec2
[src]

Formats the value using the given formatter. Read more

impl Default for Vec2
[src]

Returns the "default value" for a type. Read more

impl PartialEq for Vec2
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Add<Vec2> for Vec2
[src]

The resulting type after applying the + operator.

Adds one Vec2 to another Vec2 and returns a new Vec2.

Example:

let vec2 = some_vec2 + some_other_vec2;

impl AddAssign for Vec2
[src]

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]

The resulting type after applying the * operator.

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]

The resulting type after applying the * operator.

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]

The resulting type after applying the - operator.

Negates the values of Vec2, which in turn negates the Vec2

Example:

let negated_vec2 = -some_vec2;

impl Sub<Vec2> for Vec2
[src]

The resulting type after applying the - operator.

Subtracts one Vec2 from another Vec2 and returns a new Vec2.

Example:

let vec2 = some_vec2 - some_other_vec2;

impl SubAssign for Vec2
[src]

Subtracts one Vec2 from another Vec2 and re-assigns the first Vec2 to the new Vec2.

Example:

some_vec2 -= some_other_vec2;

Auto Trait Implementations

impl Send for Vec2

impl Sync for Vec2