Trait vector2math::Vector2[][src]

pub trait Vector2: Copy {
    type Scalar: Scalar;
    fn x(&self) -> Self::Scalar;
fn y(&self) -> Self::Scalar;
fn new(x: Self::Scalar, y: Self::Scalar) -> Self; fn set_x(&mut self, x: Self::Scalar) { ... }
fn set_y(&mut self, y: Self::Scalar) { ... }
fn with_x(self, x: Self::Scalar) -> Self { ... }
fn with_y(self, y: Self::Scalar) -> Self { ... }
fn square(s: Self::Scalar) -> Self { ... }
fn map_into<V>(self) -> V
    where
        V: Vector2,
        V::Scalar: From<Self::Scalar>
, { ... }
fn map_vec2(self) -> [Self::Scalar; 2] { ... }
fn map_dims<F>(self, f: F) -> Self
    where
        F: FnMut(Self::Scalar) -> Self::Scalar
, { ... }
fn map_with<V, F>(self, f: F) -> V
    where
        V: Vector2,
        F: FnMut(Self::Scalar) -> V::Scalar
, { ... }
fn neg(self) -> Self
    where
        Self::Scalar: Neg<Output = Self::Scalar>
, { ... }
fn add(self, other: Self) -> Self { ... }
fn sub(self, other: Self) -> Self { ... }
fn mul(self, by: Self::Scalar) -> Self { ... }
fn mul2(self, other: Self) -> Self { ... }
fn div(self, by: Self::Scalar) -> Self { ... }
fn div2(self, other: Self) -> Self { ... }
fn add_assign(&mut self, other: Self) { ... }
fn sub_assign(&mut self, other: Self) { ... }
fn mul_assign(&mut self, by: Self::Scalar) { ... }
fn mul2_assign(&mut self, other: Self) { ... }
fn div_assign(&mut self, by: Self::Scalar) { ... }
fn div2_assign(&mut self, other: Self) { ... }
fn max_dim(self) -> Self::Scalar { ... }
fn min_dim(self) -> Self::Scalar { ... }
fn dot(self, other: Self) -> Self::Scalar { ... } }

Trait for manipulating 2D vectors

Associated Types

type Scalar: Scalar[src]

The scalar type

Loading content...

Required methods

fn x(&self) -> Self::Scalar[src]

Get the x component

fn y(&self) -> Self::Scalar[src]

Get the y component

fn new(x: Self::Scalar, y: Self::Scalar) -> Self[src]

Create a new vector from an x and y component

Loading content...

Provided methods

fn set_x(&mut self, x: Self::Scalar)[src]

Set the x component

fn set_y(&mut self, y: Self::Scalar)[src]

Set the y component

fn with_x(self, x: Self::Scalar) -> Self[src]

Get this vector with a different x component

fn with_y(self, y: Self::Scalar) -> Self[src]

Get this vector with a different y component

fn square(s: Self::Scalar) -> Self[src]

Create a new square vector

fn map_into<V>(self) -> V where
    V: Vector2,
    V::Scalar: From<Self::Scalar>, 
[src]

Map this vector to a vector of another type

fn map_vec2(self) -> [Self::Scalar; 2][src]

Map this vector to a [Self::Scalar; 2]

This is an alias for Vector2::map_into::<[Self::Scalar; 2]>() that is more concise

fn map_dims<F>(self, f: F) -> Self where
    F: FnMut(Self::Scalar) -> Self::Scalar
[src]

Map the individual components of this vector

fn map_with<V, F>(self, f: F) -> V where
    V: Vector2,
    F: FnMut(Self::Scalar) -> V::Scalar
[src]

Map this vector to a vector of another type using a function

fn neg(self) -> Self where
    Self::Scalar: Neg<Output = Self::Scalar>, 
[src]

Negate the vector

fn add(self, other: Self) -> Self[src]

Add this vector to another

fn sub(self, other: Self) -> Self[src]

Subtract another vector from this one

fn mul(self, by: Self::Scalar) -> Self[src]

Multiply this vector by a scalar

fn mul2(self, other: Self) -> Self[src]

Multiply this vector component-wise by another

fn div(self, by: Self::Scalar) -> Self[src]

Divide this vector by a scalar

fn div2(self, other: Self) -> Self[src]

Divide this vector component-wise by another

fn add_assign(&mut self, other: Self)[src]

Add another vector into this one

fn sub_assign(&mut self, other: Self)[src]

Subtract another vector into this one

fn mul_assign(&mut self, by: Self::Scalar)[src]

Multiply a scalar into this vector

fn mul2_assign(&mut self, other: Self)[src]

Multiply another vector component-wise into this one

fn div_assign(&mut self, by: Self::Scalar)[src]

Divide a scalar into this vector

fn div2_assign(&mut self, other: Self)[src]

Divide another vector component-wise into this one

fn max_dim(self) -> Self::Scalar[src]

Get the value of the dimension with the higher magnitude

fn min_dim(self) -> Self::Scalar[src]

Get the value of the dimension with the lower magnitude

fn dot(self, other: Self) -> Self::Scalar[src]

Get the dot product of this vector and another

Loading content...

Implementors

impl Vector2 for f32x2[src]

This is supported on crate feature simd only.

type Scalar = f32

impl Vector2 for f64x2[src]

This is supported on crate feature simd only.

type Scalar = f64

impl Vector2 for i8x2[src]

This is supported on crate feature simd only.

type Scalar = i8

impl Vector2 for i16x2[src]

This is supported on crate feature simd only.

type Scalar = i16

impl Vector2 for i32x2[src]

This is supported on crate feature simd only.

type Scalar = i32

impl Vector2 for i64x2[src]

This is supported on crate feature simd only.

type Scalar = i64

impl Vector2 for u8x2[src]

This is supported on crate feature simd only.

type Scalar = u8

impl Vector2 for u16x2[src]

This is supported on crate feature simd only.

type Scalar = u16

impl Vector2 for u32x2[src]

This is supported on crate feature simd only.

type Scalar = u32

impl Vector2 for u64x2[src]

This is supported on crate feature simd only.

type Scalar = u64

impl<P> Vector2 for P where
    P: Pair + Copy,
    P::Item: Scalar
[src]

type Scalar = P::Item

Loading content...