[][src]Struct quicksilver::geom::Vector

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

A 2D vector with an arbitrary numeric type

Fields

x: f32

The x coordinate of the vector

y: f32

The y coordinate of the vector

Methods

impl Vector[src]

pub const ZERO: Vector[src]

A vector with x = 0, y = 0

pub const X: Vector[src]

A vector with x = 1, y = 0

pub const Y: Vector[src]

A vector with x = 0, y = 1

pub const ONE: Vector[src]

A vector with x = 1, y = 1

impl Vector[src]

pub fn new(x: impl Scalar, y: impl Scalar) -> Vector[src]

Create a new vector

pub fn into_vector(self) -> Vector2<f32>[src]

Convert this vector into an nalgebra Vector2

pub fn into_point(self) -> Point2<f32>[src]

Convert this vector into an nalgebra Point2

pub fn from_angle<T: Scalar>(angle: T) -> Vector[src]

Create a unit vector at a given angle

pub fn len2(self) -> f32[src]

Get the squared length of the vector (faster than getting the length)

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

Get the length of the vector

#[must_use] pub fn clamp(
    self,
    min_bound: impl Into<Vector>,
    max_bound: impl Into<Vector>
) -> Vector
[src]

Clamp a vector somewhere between a minimum and a maximum

pub fn cross(self, other: impl Into<Vector>) -> f32[src]

Get the cross product of a vector

pub fn dot(self, other: impl Into<Vector>) -> f32[src]

Get the dot product of a vector

#[must_use] pub fn normalize(self) -> Vector[src]

Normalize the vector's length from [0, 1]

#[must_use] pub fn x_comp(self) -> Vector[src]

Get only the X component of the Vector, represented as a vector

#[must_use] pub fn y_comp(self) -> Vector[src]

Get only the Y component of the Vector, represented as a vector

#[must_use] pub fn recip(self) -> Vector[src]

Get the vector equal to Vector(1 / x, 1 / y)

#[must_use] pub fn times(self, other: impl Into<Vector>) -> Vector[src]

Multiply the components in the matching places

pub fn angle(self) -> f32[src]

Get the angle a vector forms with the positive x-axis, counter clockwise

#[must_use] pub fn with_len(self, length: f32) -> Vector[src]

Create a vector with the same angle and the given length

pub fn distance(self, other: impl Into<Vector>) -> f32[src]

Get the Euclidean distance to another vector

pub fn min(self, other: impl Into<Vector>) -> Vector[src]

Get a vector with the minimum of each component of this and another vector

pub fn max(self, other: impl Into<Vector>) -> Vector[src]

Get a vector with the maximum of each component of this and another vector

Trait Implementations

impl Shape for Vector[src]

impl Drawable for Vector[src]

impl From<Matrix<f32, U2, U1, <DefaultAllocator as Allocator<f32, U2, U1>>::Buffer>> for Vector[src]

impl From<Point<f32, U2>> for Vector[src]

impl From<Vector> for LogicalPosition[src]

impl From<Vector> for PhysicalPosition[src]

impl From<LogicalPosition> for Vector[src]

impl From<PhysicalPosition> for Vector[src]

impl From<Vector> for LogicalSize[src]

impl From<Vector> for PhysicalSize[src]

impl From<LogicalSize> for Vector[src]

impl From<PhysicalSize> for Vector[src]

impl<T: Scalar, U: Scalar> From<(T, U)> for Vector[src]

impl Clone for Vector[src]

impl Copy for Vector[src]

impl Default for Vector[src]

impl Eq for Vector[src]

impl PartialEq<Vector> for Vector[src]

impl Display for Vector[src]

impl Debug for Vector[src]

impl<T: Scalar> Div<T> for Vector[src]

type Output = Vector

The resulting type after applying the / operator.

impl Sub<Vector> for Vector[src]

type Output = Vector

The resulting type after applying the - operator.

impl Add<Vector> for Vector[src]

type Output = Vector

The resulting type after applying the + operator.

impl<T: Scalar> Mul<T> for Vector[src]

type Output = Vector

The resulting type after applying the * operator.

impl Mul<Vector> for Transform[src]

Transform a vector

type Output = Vector

The resulting type after applying the * operator.

impl Neg for Vector[src]

type Output = Vector

The resulting type after applying the - operator.

impl AddAssign<Vector> for Vector[src]

impl SubAssign<Vector> for Vector[src]

impl<T: Scalar> MulAssign<T> for Vector[src]

impl<T: Scalar> DivAssign<T> for Vector[src]

impl Distribution<Vector> for Standard[src]

impl Serialize for Vector[src]

impl<'de> Deserialize<'de> for Vector[src]

Auto Trait Implementations

impl Send for Vector

impl Sync for Vector

impl Unpin for Vector

impl UnwindSafe for Vector

impl RefUnwindSafe for Vector

Blanket Implementations

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

impl<T> From<T> for 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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<T> SetParameter for T

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Any + Debug
[src]

impl<T, Right> ClosedAdd<Right> for T where
    T: Add<Right, Output = T> + AddAssign<Right>, 
[src]

impl<T, Right> ClosedMul<Right> for T where
    T: Mul<Right, Output = T> + MulAssign<Right>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, Right> ClosedDiv<Right> for T where
    T: Div<Right, Output = T> + DivAssign<Right>, 
[src]

impl<T> ClosedNeg for T where
    T: Neg<Output = T>, 
[src]

impl<T, Right> ClosedSub<Right> for T where
    T: Sub<Right, Output = T> + SubAssign<Right>, 
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

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

impl<T> Downcast for T where
    T: Any

impl<T> Slottable for T where
    T: Copy
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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