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

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]

`impl Vector`

`pub const `**ZERO**: Vector

[src]

**ZERO**: Vector

A vector with x = 0, y = 0

`pub const `**X**: Vector

[src]

**X**: Vector

A vector with x = 1, y = 0

`pub const `**Y**: Vector

[src]

**Y**: Vector

A vector with x = 0, y = 1

`pub const `**ONE**: Vector

[src]

**ONE**: Vector

A vector with x = 1, y = 1

`impl Vector`

[src]

`impl Vector`

`pub fn new(`

x: impl Scalar,

y: impl Scalar

) -> Vector

[src]

`pub fn new(`

x: impl Scalar,

y: impl Scalar

) -> Vector

Create a new vector

`pub fn into_vector(self) -> Vector2<f32>`

[src]

`pub fn into_vector(self) -> Vector2<f32>`

Convert this vector into an nalgebra Vector2

`pub fn into_point(self) -> Point2<f32>`

[src]

`pub fn into_point(self) -> Point2<f32>`

Convert this vector into an nalgebra Point2

`pub fn from_angle<T: Scalar>(angle: T) -> Vector`

[src]

`pub fn from_angle<T: Scalar>(angle: T) -> Vector`

Create a unit vector at a given angle

`pub fn len2(self) -> f32`

[src]

`pub fn len2(self) -> f32`

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

`pub fn len(self) -> f32`

[src]

`pub fn len(self) -> f32`

Get the length of the vector

```
#[must_use]
pub fn clamp(
```

self,

min_bound: impl Into<Vector>,

max_bound: impl Into<Vector>

) -> Vector

[src]

```
#[must_use]
pub fn clamp(
```

self,

min_bound: impl Into<Vector>,

max_bound: impl Into<Vector>

) -> Vector

Clamp a vector somewhere between a minimum and a maximum

`pub fn cross(`

self,

other: impl Into<Vector>

) -> f32

[src]

`pub fn cross(`

self,

other: impl Into<Vector>

) -> f32

Get the cross product of a vector

`pub fn dot(`

self,

other: impl Into<Vector>

) -> f32

[src]

`pub fn dot(`

self,

other: impl Into<Vector>

) -> f32

Get the dot product of a vector

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

[src]

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

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

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

[src]

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

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

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

[src]

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

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

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

[src]

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

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

```
#[must_use]
pub fn times(
```

self,

other: impl Into<Vector>

) -> Vector

[src]

```
#[must_use]
pub fn times(
```

self,

other: impl Into<Vector>

) -> Vector

Multiply the components in the matching places

`pub fn angle(self) -> f32`

[src]

`pub fn angle(self) -> f32`

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

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

[src]

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

Create a vector with the same angle and the given length

`pub fn distance(`

self,

other: impl Into<Vector>

) -> f32

[src]

`pub fn distance(`

self,

other: impl Into<Vector>

) -> f32

Get the Euclidean distance to another vector

`pub fn min(`

self,

other: impl Into<Vector>

) -> Vector

[src]

`pub fn min(`

self,

other: impl Into<Vector>

) -> Vector

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

`pub fn max(`

self,

other: impl Into<Vector>

) -> Vector

[src]

`pub fn max(`

self,

other: impl Into<Vector>

) -> Vector

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

## Trait Implementations

`impl Shape for Vector`

[src]

`impl Shape for Vector`

`fn contains(`

&self,

v: impl Into<Vector>

) -> bool

[src]

`fn contains(`

&self,

v: impl Into<Vector>

) -> bool

`fn overlaps(`

&self,

shape: &impl Shape

) -> bool

[src]

`fn overlaps(`

&self,

shape: &impl Shape

) -> bool

`fn center(&self) -> Vector`

[src]

`fn center(&self) -> Vector`

`fn bounding_box(&self) -> Rectangle`

[src]

`fn bounding_box(&self) -> Rectangle`

`fn translate(`

&self,

v: impl Into<Vector>

) -> Vector

[src]

`fn translate(`

&self,

v: impl Into<Vector>

) -> Vector

```
#[must_use]
fn intersects(&self, line: &Line) -> bool
```

[src]

```
#[must_use]
fn intersects(&self, line: &Line) -> bool
```

If any area bounded by the shape falls on the line

```
#[must_use]
fn overlaps_circle(&self, circle: &Circle) -> bool
```

[src]

```
#[must_use]
fn overlaps_circle(&self, circle: &Circle) -> bool
```

If any area is bounded by both the shape and the circle

```
#[must_use]
fn overlaps_rectangle(&self, rectangle: &Rectangle) -> bool
```

[src]

```
#[must_use]
fn overlaps_rectangle(&self, rectangle: &Rectangle) -> bool
```

If any area is bounded by both the shape and the rectangle

```
#[must_use]
fn constrain(&self, outer: &Rectangle) -> Self where
```

Self: Sized,

[src]

```
#[must_use]
fn constrain(&self, outer: &Rectangle) -> Self where
```

Self: Sized,

Create a copy of the shape that is contained within the bound

```
#[must_use]
fn with_center(
```

&self,

center: impl Into<Vector>

) -> Self where

Self: Sized,

[src]

```
#[must_use]
fn with_center(
```

&self,

center: impl Into<Vector>

) -> Self where

Self: Sized,

Create a copy of the shape with an offset center

`impl Drawable for Vector`

[src]

`impl Drawable for Vector`

`impl PartialEq<Vector> for Vector`

[src]

`impl PartialEq<Vector> for Vector`

`fn eq(&self, other: &Vector) -> bool`

[src]

`fn eq(&self, other: &Vector) -> bool`

```
#[must_use]
fn ne(&self, other: &Rhs) -> bool
```

1.0.0[src]

```
#[must_use]
fn ne(&self, other: &Rhs) -> bool
```

This method tests for `!=`

.

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

[src]

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

`impl From<Point<f32, U2>> for Vector`

[src]

`impl From<Point<f32, U2>> for Vector`

`impl From<Vector> for LogicalPosition`

[src]

`impl From<Vector> for LogicalPosition`

`impl From<Vector> for PhysicalPosition`

[src]

`impl From<Vector> for PhysicalPosition`

`impl From<LogicalPosition> for Vector`

[src]

`impl From<LogicalPosition> for Vector`

`impl From<PhysicalPosition> for Vector`

[src]

`impl From<PhysicalPosition> for Vector`

`impl From<Vector> for LogicalSize`

[src]

`impl From<Vector> for LogicalSize`

`impl From<Vector> for PhysicalSize`

[src]

`impl From<Vector> for PhysicalSize`

`impl From<LogicalSize> for Vector`

[src]

`impl From<LogicalSize> for Vector`

`impl From<PhysicalSize> for Vector`

[src]

`impl From<PhysicalSize> for Vector`

`impl<T: Scalar, U: Scalar> From<(T, U)> for Vector`

[src]

`impl<T: Scalar, U: Scalar> From<(T, U)> for Vector`

`impl Clone for Vector`

[src]

`impl Clone for Vector`

`fn clone(&self) -> Vector`

[src]

`fn clone(&self) -> Vector`

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

1.0.0[src]

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

Performs copy-assignment from `source`

. Read more

`impl Copy for Vector`

[src]

`impl Copy for Vector`

`impl Eq for Vector`

[src]

`impl Eq for Vector`

`impl Default for Vector`

[src]

`impl Default for Vector`

`impl Display for Vector`

[src]

`impl Display for Vector`

`impl Debug for Vector`

[src]

`impl Debug for Vector`

`impl<T: Scalar> Div<T> for Vector`

[src]

`impl<T: Scalar> Div<T> for Vector`

`type Output = Vector`

The resulting type after applying the `/`

operator.

`fn div(self, rhs: T) -> Vector`

[src]

`fn div(self, rhs: T) -> Vector`

`impl Add<Vector> for Vector`

[src]

`impl Add<Vector> for Vector`

`type Output = Vector`

The resulting type after applying the `+`

operator.

`fn add(self, rhs: Vector) -> Vector`

[src]

`fn add(self, rhs: Vector) -> Vector`

`impl Sub<Vector> for Vector`

[src]

`impl Sub<Vector> for Vector`

`type Output = Vector`

The resulting type after applying the `-`

operator.

`fn sub(self, rhs: Vector) -> Vector`

[src]

`fn sub(self, rhs: Vector) -> Vector`

`impl<T: Scalar> Mul<T> for Vector`

[src]

`impl<T: Scalar> Mul<T> for Vector`

`type Output = Vector`

The resulting type after applying the `*`

operator.

`fn mul(self, rhs: T) -> Vector`

[src]

`fn mul(self, rhs: T) -> Vector`

`impl Mul<Vector> for Transform`

[src]

`impl Mul<Vector> for Transform`

Transform a vector

`type Output = Vector`

The resulting type after applying the `*`

operator.

`fn mul(self, other: Vector) -> Vector`

[src]

`fn mul(self, other: Vector) -> Vector`

`impl Neg for Vector`

[src]

`impl Neg for Vector`

`impl AddAssign<Vector> for Vector`

[src]

`impl AddAssign<Vector> for Vector`

`fn add_assign(&mut self, rhs: Vector)`

[src]

`fn add_assign(&mut self, rhs: Vector)`

`impl SubAssign<Vector> for Vector`

[src]

`impl SubAssign<Vector> for Vector`

`fn sub_assign(&mut self, rhs: Vector)`

[src]

`fn sub_assign(&mut self, rhs: Vector)`

`impl<T: Scalar> MulAssign<T> for Vector`

[src]

`impl<T: Scalar> MulAssign<T> for Vector`

`fn mul_assign(&mut self, rhs: T)`

[src]

`fn mul_assign(&mut self, rhs: T)`

`impl<T: Scalar> DivAssign<T> for Vector`

[src]

`impl<T: Scalar> DivAssign<T> for Vector`

`fn div_assign(&mut self, rhs: T)`

[src]

`fn div_assign(&mut self, rhs: T)`

`impl Distribution<Vector> for Standard`

[src]

`impl Distribution<Vector> for Standard`

`fn sample<R: Rng + ?Sized>(&self, rand: &mut R) -> Vector`

[src]

`fn sample<R: Rng + ?Sized>(&self, rand: &mut R) -> Vector`

`fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where`

R: Rng,

[src]

`fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where`

R: Rng,

Create an iterator that generates random values of `T`

, using `rng`

as the source of randomness. Read more

`impl Serialize for Vector`

[src]

`impl Serialize for Vector`

`fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where`

__S: Serializer,

[src]

`fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where`

__S: Serializer,

`impl<'de> Deserialize<'de> for Vector`

[src]

`impl<'de> Deserialize<'de> for Vector`

`fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where`

__D: Deserializer<'de>,

[src]

`fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where`

__D: Deserializer<'de>,

## Auto Trait Implementations

## Blanket Implementations

`impl<T> From for T`

[src]

`impl<T> From for T`

`impl<T, U> Into for T where`

U: From<T>,

[src]

`impl<T, U> Into for T where`

U: From<T>,

`impl<T> ToOwned for T where`

T: Clone,

[src]

`impl<T> ToOwned for T where`

T: Clone,

`impl<T> ToString for T where`

T: Display + ?Sized,

[src]

`impl<T> ToString for T where`

T: Display + ?Sized,

`impl<T, U> TryFrom for T where`

T: From<U>,

[src]

`impl<T, U> TryFrom for T where`

T: From<U>,

`type Error = !`

`try_from`

)The type returned in the event of a conversion error.

`fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`

[src]

`fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`

`impl<T> Borrow for T where`

T: ?Sized,

[src]

`impl<T> Borrow for T where`

T: ?Sized,

`impl<T> BorrowMut for T where`

T: ?Sized,

[src]

`impl<T> BorrowMut for T where`

T: ?Sized,

`fn borrow_mut(&mut self) -> &mut T`

[src]

`fn borrow_mut(&mut self) -> &mut T`

`impl<T, U> TryInto for T where`

U: TryFrom<T>,

[src]

`impl<T, U> TryInto for T where`

U: TryFrom<T>,

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

`try_from`

)The type returned in the event of a conversion error.

`fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`

[src]

`fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`

`impl<T> Any for T where`

T: 'static + ?Sized,

[src]

`impl<T> Any for T where`

T: 'static + ?Sized,

`fn get_type_id(&self) -> TypeId`

[src]

`fn get_type_id(&self) -> TypeId`

`impl<T> SetParameter for T`

`impl<T> SetParameter for T`

`fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where`

T: Parameter<Self>,

`fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where`

T: Parameter<Self>,

Sets `value`

as a parameter of `self`

.

`impl<T> Erased for T`

`impl<T> Erased for T`

`impl<T> Scalar for T where`

T: Copy + PartialEq<T> + Any + Debug,

[src]

`impl<T> Scalar for T where`

T: Copy + PartialEq<T> + Any + Debug,

`impl<T, Right> ClosedMul for T where`

T: Mul<Right, Output = T> + MulAssign<Right>,

[src]

`impl<T, Right> ClosedMul for T where`

T: Mul<Right, Output = T> + MulAssign<Right>,

`impl<T, Right> ClosedAdd for T where`

T: Add<Right, Output = T> + AddAssign<Right>,

[src]

`impl<T, Right> ClosedAdd for T where`

T: Add<Right, Output = T> + AddAssign<Right>,

`impl<T> Same for T`

`impl<T> Same for T`

`type Output = T`

Should always be `Self`

`impl<T, Right> ClosedSub for T where`

T: Sub<Right, Output = T> + SubAssign<Right>,

[src]

`impl<T, Right> ClosedSub for T where`

T: Sub<Right, Output = T> + SubAssign<Right>,

`impl<T> ClosedNeg for T where`

T: Neg<Output = T>,

[src]

`impl<T> ClosedNeg for T where`

T: Neg<Output = T>,

`impl<T, Right> ClosedDiv for T where`

T: Div<Right, Output = T> + DivAssign<Right>,

[src]

`impl<T, Right> ClosedDiv for T where`

T: Div<Right, Output = T> + DivAssign<Right>,

`impl<SS, SP> SupersetOf for SP where`

SS: SubsetOf<SP>,

[src]

`impl<SS, SP> SupersetOf for SP where`

SS: SubsetOf<SP>,

`fn to_subset(&self) -> Option<SS>`

[src]

`fn to_subset(&self) -> Option<SS>`

`fn is_in_subset(&self) -> bool`

[src]

`fn is_in_subset(&self) -> bool`

`unsafe fn to_subset_unchecked(&self) -> SS`

[src]

`unsafe fn to_subset_unchecked(&self) -> SS`

`fn from_subset(element: &SS) -> SP`

[src]

`fn from_subset(element: &SS) -> SP`

`impl<T> DeserializeOwned for T where`

T: Deserialize<'de>,

[src]

`impl<T> DeserializeOwned for T where`

T: Deserialize<'de>,