[][src]Struct batbox::Vec2

#[repr(C)]pub struct Vec2<T> {
    pub x: T,
    pub y: T,
}

2-d vector.

Fields

x: Ty: T

Implementations

impl<T> Vec2<T>[src]

pub fn extend(self, z: T) -> Vec3<T>[src]

Extend into a 3-d vector.

Examples

use batbox::*;
assert_eq!(vec2(1, 2).extend(3), vec3(1, 2, 3));

pub fn map<U, F: Fn(T) -> U>(self, f: F) -> Vec2<U>[src]

impl<T: Num + Copy> Vec2<T>[src]

pub fn dot(a: Self, b: Self) -> T[src]

Calculate dot product of two vectors.

Examples

use batbox::*;
assert_eq!(Vec2::dot(vec2(1, 2), vec2(3, 4)), 11);

pub fn skew(a: Self, b: Self) -> T[src]

Calculate skew product of two vectors.

Examples

use batbox::*;
assert_eq!(Vec2::skew(vec2(1, 2), vec2(3, 4)), -2);

impl<T: Neg<Output = T>> Vec2<T>[src]

pub fn rotate_90(self) -> Self[src]

impl<T: Float> Vec2<T>[src]

pub fn normalize(self) -> Self[src]

Normalize a vector.

Examples

use batbox::*;
let v: Vec2<f64> = vec2(1.0, 2.0);
assert!((v.normalize().len() - 1.0).abs() < 1e-5);

pub fn len(self) -> T[src]

Calculate length of a vector.

pub fn rotated(v: Self, angle: T) -> Self[src]

Rotate a vector by a given angle.

pub fn clamp(self, max_len: T) -> Self[src]

pub fn arg(self) -> T[src]

Trait Implementations

impl<T: Add<Output = T>> Add<Vec2<T>> for Vec2<T>[src]

type Output = Self

The resulting type after applying the + operator.

impl<T: AddAssign> AddAssign<Vec2<T>> for Vec2<T>[src]

impl<T: Clone> Clone for Vec2<T>[src]

impl<T: Copy> Copy for Vec2<T>[src]

impl<T: Debug> Debug for Vec2<T>[src]

impl<T> Deref for Vec2<T>[src]

type Target = [T; 2]

The resulting type after dereferencing.

impl<T> DerefMut for Vec2<T>[src]

impl<'de, T> Deserialize<'de> for Vec2<T> where
    T: Deserialize<'de>, 
[src]

impl<T: Display> Display for Vec2<T>[src]

impl Distribution<Vec2<f32>> for UnitCircleInside[src]

impl<T: Copy + Div<Output = T>> Div<T> for Vec2<T>[src]

type Output = Self

The resulting type after applying the / operator.

impl<T: Copy + DivAssign> DivAssign<T> for Vec2<T>[src]

impl<T: Eq> Eq for Vec2<T>[src]

impl<T> From<[T; 2]> for Vec2<T>[src]

impl<T: Hash> Hash for Vec2<T>[src]

impl<T: Copy + Mul<Output = T>> Mul<T> for Vec2<T>[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Vec2<f32>> for f32[src]

type Output = Vec2<f32>

The resulting type after applying the * operator.

impl Mul<Vec2<f64>> for f64[src]

type Output = Vec2<f64>

The resulting type after applying the * operator.

impl Mul<Vec2<i16>> for i16[src]

type Output = Vec2<i16>

The resulting type after applying the * operator.

impl Mul<Vec2<i32>> for i32[src]

type Output = Vec2<i32>

The resulting type after applying the * operator.

impl Mul<Vec2<i64>> for i64[src]

type Output = Vec2<i64>

The resulting type after applying the * operator.

impl Mul<Vec2<i8>> for i8[src]

type Output = Vec2<i8>

The resulting type after applying the * operator.

impl Mul<Vec2<isize>> for isize[src]

type Output = Vec2<isize>

The resulting type after applying the * operator.

impl Mul<Vec2<u16>> for u16[src]

type Output = Vec2<u16>

The resulting type after applying the * operator.

impl Mul<Vec2<u32>> for u32[src]

type Output = Vec2<u32>

The resulting type after applying the * operator.

impl Mul<Vec2<u64>> for u64[src]

type Output = Vec2<u64>

The resulting type after applying the * operator.

impl Mul<Vec2<u8>> for u8[src]

type Output = Vec2<u8>

The resulting type after applying the * operator.

impl Mul<Vec2<usize>> for usize[src]

type Output = Vec2<usize>

The resulting type after applying the * operator.

impl<T: Copy + MulAssign> MulAssign<T> for Vec2<T>[src]

impl<T: Neg<Output = T>> Neg for Vec2<T>[src]

type Output = Self

The resulting type after applying the - operator.

impl<T: PartialEq> PartialEq<Vec2<T>> for Vec2<T>[src]

impl<T> Schematic for Vec2<T> where
    T: Schematic + 'static,
    T: Schematic + 'static,
    T: Schematic
[src]

impl<T> Serialize for Vec2<T> where
    T: Serialize
[src]

impl<T> StructuralEq for Vec2<T>[src]

impl<T> StructuralPartialEq for Vec2<T>[src]

impl<T: Sub<Output = T>> Sub<Vec2<T>> for Vec2<T>[src]

type Output = Self

The resulting type after applying the - operator.

impl<T: SubAssign> SubAssign<Vec2<T>> for Vec2<T>[src]

impl<T> Trans for Vec2<T> where
    T: Trans,
    T: Trans
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Vec2<T> where
    T: RefUnwindSafe

impl<T> Send for Vec2<T> where
    T: Send

impl<T> Sync for Vec2<T> where
    T: Sync

impl<T> Unpin for Vec2<T> where
    T: Unpin

impl<T> UnwindSafe for Vec2<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,