Struct cgmath::Vector2 [] [src]

pub struct Vector2<S> {
    pub x: S,
    pub y: S,
}

Fields

x
y

Methods

impl<S> Vector2<S>

fn new(x: S, y: S) -> Vector2<S>

Construct a new vector, using the provided values.

impl<S: Copy + Neg<Output=S>> Vector2<S>

fn neg_self(&mut self)

Negate this vector in-place (multiply by -1).

impl<S: NumCast + Copy> Vector2<S>

fn cast<T: NumCast>(&self) -> Vector2<T>

Component-wise casting to another type

impl<S: BaseNum> Vector2<S>

Operations specific to numeric two-dimensional vectors.

fn unit_x() -> Vector2<S>

A unit vector in the x direction.

fn unit_y() -> Vector2<S>

A unit vector in the y direction.

fn perp_dot(&self, other: &Vector2<S>) -> S

The perpendicular dot product of the vector and other.

fn extend(&self, z: S) -> Vector3<S>

Create a Vector3, using the x and y values from this vector, and the provided z.

Trait Implementations

impl<S: Zero + BaseNum> Zero for Vector2<S>

fn zero() -> Vector2<S>

fn is_zero(&self) -> bool

impl<S: One + BaseNum> One for Vector2<S>

fn one() -> Vector2<S>

impl<S> FixedArray<[S; 2]> for Vector2<S>

fn into_fixed(self) -> [S; 2]

fn as_fixed<'a>(&'a self) -> &'a [S; 2]

fn as_mut_fixed<'a>(&'a mut self) -> &'a mut [S; 2]

fn from_fixed(_v: [S; 2]) -> Vector2<S>

fn from_fixed_ref<'a>(v: &'a [S; 2]) -> &'a Vector2<S>

fn from_fixed_mut<'a>(v: &'a mut [S; 2]) -> &'a mut Vector2<S>

impl<S: Copy> Index<usize> for Vector2<S>

type Output = S

fn index<'a>(&'a self, i: usize) -> &'a S

impl<S: Copy> IndexMut<usize> for Vector2<S>

fn index_mut<'a>(&'a mut self, i: usize) -> &'a mut S

impl<S: Copy> Array1<S> for Vector2<S>

fn map<F>(&mut self, op: F) -> Vector2<S> where F: FnMut(S) -> S

fn ptr<'a>(&'a self) -> &'a Element

fn mut_ptr<'a>(&'a mut self) -> &'a mut Element

fn swap_elems(&mut self, i: usize, j: usize)

fn replace_elem(&mut self, i: usize, src: Element) -> Element

impl<S: BaseNum> Vector<S> for Vector2<S>

fn from_value(s: S) -> Vector2<S>

fn add_s(&self, s: S) -> Vector2<S>

fn sub_s(&self, s: S) -> Vector2<S>

fn mul_s(&self, s: S) -> Vector2<S>

fn div_s(&self, s: S) -> Vector2<S>

fn rem_s(&self, s: S) -> Vector2<S>

fn add_v(&self, v: &Vector2<S>) -> Vector2<S>

fn sub_v(&self, v: &Vector2<S>) -> Vector2<S>

fn mul_v(&self, v: &Vector2<S>) -> Vector2<S>

fn div_v(&self, v: &Vector2<S>) -> Vector2<S>

fn rem_v(&self, v: &Vector2<S>) -> Vector2<S>

fn add_self_s(&mut self, s: S)

fn sub_self_s(&mut self, s: S)

fn mul_self_s(&mut self, s: S)

fn div_self_s(&mut self, s: S)

fn rem_self_s(&mut self, s: S)

fn add_self_v(&mut self, v: &Vector2<S>)

fn sub_self_v(&mut self, v: &Vector2<S>)

fn mul_self_v(&mut self, v: &Vector2<S>)

fn div_self_v(&mut self, v: &Vector2<S>)

fn rem_self_v(&mut self, v: &Vector2<S>)

fn comp_add(&self) -> S

fn comp_mul(&self) -> S

fn comp_min(&self) -> S

fn comp_max(&self) -> S

fn dot(&self, v: &Self) -> S

impl<S: BaseNum> Add for Vector2<S>

type Output = Vector2<S>

fn add(self, v: Vector2<S>) -> Vector2<S>

impl<S: BaseNum> Sub for Vector2<S>

type Output = Vector2<S>

fn sub(self, v: Vector2<S>) -> Vector2<S>

impl<S: Neg<Output=S>> Neg for Vector2<S>

type Output = Vector2<S>

fn neg(self) -> Vector2<S>

impl<S: BaseNum> Mul for Vector2<S>

type Output = Vector2<S>

fn mul(self, v: Vector2<S>) -> Vector2<S>

impl<S: BaseNum> Div for Vector2<S>

type Output = Vector2<S>

fn div(self, v: Vector2<S>) -> Vector2<S>

impl<S: BaseNum> Rem for Vector2<S>

type Output = Vector2<S>

fn rem(self, v: Vector2<S>) -> Vector2<S>

impl<S: BaseFloat> ApproxEq<S> for Vector2<S>

fn approx_eq_eps(&self, other: &Vector2<S>, epsilon: &S) -> bool

fn approx_epsilon(_hack: Option<Self>) -> T

fn approx_eq(&self, other: &Self) -> bool

impl<S: BaseFloat + Rand> Rand for Vector2<S>

fn rand<R: Rng>(rng: &mut R) -> Vector2<S>

impl<S: BaseFloat> EuclideanVector<S> for Vector2<S>

fn angle(&self, other: &Vector2<S>) -> Rad<S>

fn is_perpendicular(&self, other: &Self) -> bool

fn length2(&self) -> S

fn length(&self) -> S

fn normalize(&self) -> Self

fn normalize_to(&self, length: S) -> Self

fn lerp(&self, other: &Self, amount: S) -> Self

fn normalize_self(&mut self)

fn normalize_self_to(&mut self, length: S)

fn lerp_self(&mut self, other: &Self, amount: S)

impl<S: BaseNum> Debug for Vector2<S>

fn fmt(&self, f: &mut Formatter) -> Result

Derived Implementations

impl<S: Decodable> Decodable for Vector2<S>

fn decode<__D: Decoder>(__arg_0: &mut __D) -> Result<Vector2<S>, __D::Error>

impl<S: Encodable> Encodable for Vector2<S>

fn encode<__S: Encoder>(&self, __arg_0: &mut __S) -> Result<(), __S::Error>

impl<S: Hash> Hash for Vector2<S>

fn hash<__H: Hasher>(&self, __arg_0: &mut __H)

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher

impl<S: Clone> Clone for Vector2<S>

fn clone(&self) -> Vector2<S>

fn clone_from(&mut self, source: &Self)

impl<S: Copy> Copy for Vector2<S>

impl<S: Eq> Eq for Vector2<S>

impl<S: PartialEq> PartialEq for Vector2<S>

fn eq(&self, __arg_0: &Vector2<S>) -> bool

fn ne(&self, __arg_0: &Vector2<S>) -> bool