Struct cgmath::Vector2 [] [src]

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

A 2-dimensional vector.

This type is marked as #[repr(C)].

Fields

The x component of the vector.

The y component of the vector.

Methods

impl<S> Vector2<S>
[src]

[src]

Construct a new vector, using the provided values.

impl<S: NumCast + Copy> Vector2<S>
[src]

[src]

Component-wise casting to another type.

impl<S: BaseNum> Vector2<S>
[src]

[src]

A unit vector in the x direction.

[src]

A unit vector in the y direction.

[src]

The perpendicular dot product of the vector and other.

[src]

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

Trait Implementations

impl<S: PartialEq> PartialEq for Vector2<S>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<S: Eq> Eq for Vector2<S>
[src]

impl<S: Copy> Copy for Vector2<S>
[src]

impl<S: Clone> Clone for Vector2<S>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<S: Hash> Hash for Vector2<S>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<S: BaseFloat> MetricSpace for Vector2<S>
[src]

The metric to be returned by the distance function.

[src]

Returns the squared distance. Read more

[src]

The distance between two values.

impl<S: Copy> Array for Vector2<S>
[src]

[src]

Get the number of elements in the array type Read more

[src]

Construct a vector from a single value, replicating it. Read more

[src]

The sum of the elements of the array.

[src]

The product of the elements of the array.

[src]

Get the pointer to the first element of the array.

[src]

Get a mutable pointer to the first element of the array.

[src]

Swap the elements at indices i and j in-place.

impl<S: BaseNum> Zero for Vector2<S>
[src]

[src]

Returns the additive identity element of Self, 0. Read more

[src]

Returns true if self is equal to the additive identity.

impl<S: BaseNum> Sum<Vector2<S>> for Vector2<S>
[src]

[src]

Method which takes an iterator and generates Self from the elements by "summing up" the items. Read more

impl<'a, S: 'a + BaseNum> Sum<&'a Vector2<S>> for Vector2<S>
[src]

[src]

Method which takes an iterator and generates Self from the elements by "summing up" the items. Read more

impl<S: BaseNum> VectorSpace for Vector2<S>
[src]

The associated scalar.

impl<S: Neg<Output = S>> Neg for Vector2<S>
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl<S: BaseFloat> ApproxEq for Vector2<S>
[src]

Used for specifying relative comparisons.

[src]

The default tolerance to use when testing values that are close together. Read more

[src]

The default relative tolerance for testing values that are far-apart. Read more

[src]

The default ULPs to tolerate when testing values that are far-apart. Read more

[src]

A test for equality that uses a relative comparison if the values are far apart.

[src]

A test for equality that uses units in the last place (ULP) if the values are far apart.

[src]

The inverse of ApproxEq::relative_eq.

[src]

The inverse of ApproxEq::ulps_eq.

impl<S: BaseFloat + Rand> Rand for Vector2<S>
[src]

[src]

Generates a random instance of this type using the specified source of randomness. Read more

impl<S: Bounded> Bounded for Vector2<S>
[src]

[src]

returns the smallest finite number this type can represent

[src]

returns the largest finite number this type can represent

impl<S: BaseNum> Add<Vector2<S>> for Vector2<S>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a, S: BaseNum> Add<&'a Vector2<S>> for Vector2<S>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a, S: BaseNum> Add<Vector2<S>> for &'a Vector2<S>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<'a, 'b, S: BaseNum> Add<&'a Vector2<S>> for &'b Vector2<S>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<S: BaseNum + AddAssign<S>> AddAssign<Vector2<S>> for Vector2<S>
[src]

[src]

Performs the += operation.

impl<S: BaseNum> Sub<Vector2<S>> for Vector2<S>
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'a, S: BaseNum> Sub<&'a Vector2<S>> for Vector2<S>
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'a, S: BaseNum> Sub<Vector2<S>> for &'a Vector2<S>
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<'a, 'b, S: BaseNum> Sub<&'a Vector2<S>> for &'b Vector2<S>
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<S: BaseNum + SubAssign<S>> SubAssign<Vector2<S>> for Vector2<S>
[src]

[src]

Performs the -= operation.

impl<S: BaseNum> Mul<S> for Vector2<S>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<'a, S: BaseNum> Mul<S> for &'a Vector2<S>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<S: BaseNum + MulAssign<S>> MulAssign<S> for Vector2<S>
[src]

[src]

Performs the *= operation.

impl<S: BaseNum> Div<S> for Vector2<S>
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<'a, S: BaseNum> Div<S> for &'a Vector2<S>
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<S: BaseNum + DivAssign<S>> DivAssign<S> for Vector2<S>
[src]

[src]

Performs the /= operation.

impl<S: BaseNum> Rem<S> for Vector2<S>
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl<'a, S: BaseNum> Rem<S> for &'a Vector2<S>
[src]

The resulting type after applying the % operator.

[src]

Performs the % operation.

impl<S: BaseNum + RemAssign<S>> RemAssign<S> for Vector2<S>
[src]

[src]

Performs the %= operation.

impl<S: BaseNum> ElementWise for Vector2<S>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<S: BaseNum> ElementWise<S> for Vector2<S>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<S> Index<usize> for Vector2<S>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<S> IndexMut<usize> for Vector2<S>
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl<S> Index<Range<usize>> for Vector2<S>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<S> IndexMut<Range<usize>> for Vector2<S>
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl<S> Index<RangeTo<usize>> for Vector2<S>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<S> IndexMut<RangeTo<usize>> for Vector2<S>
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl<S> Index<RangeFrom<usize>> for Vector2<S>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<S> IndexMut<RangeFrom<usize>> for Vector2<S>
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl<S> Index<RangeFull> for Vector2<S>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<S> IndexMut<RangeFull> for Vector2<S>
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl<S> Into<[S; 2]> for Vector2<S>
[src]

[src]

Performs the conversion.

impl<S> AsRef<[S; 2]> for Vector2<S>
[src]

[src]

Performs the conversion.

impl<S> AsMut<[S; 2]> for Vector2<S>
[src]

[src]

Performs the conversion.

impl<S: Clone> From<[S; 2]> for Vector2<S>
[src]

[src]

Performs the conversion.

impl<'a, S> From<&'a [S; 2]> for &'a Vector2<S>
[src]

[src]

Performs the conversion.

impl<'a, S> From<&'a mut [S; 2]> for &'a mut Vector2<S>
[src]

[src]

Performs the conversion.

impl<S> Into<(S, S)> for Vector2<S>
[src]

[src]

Performs the conversion.

impl<S> AsRef<(S, S)> for Vector2<S>
[src]

[src]

Performs the conversion.

impl<S> AsMut<(S, S)> for Vector2<S>
[src]

[src]

Performs the conversion.

impl<S> From<(S, S)> for Vector2<S>
[src]

[src]

Performs the conversion.

impl<'a, S> From<&'a (S, S)> for &'a Vector2<S>
[src]

[src]

Performs the conversion.

impl<'a, S> From<&'a mut (S, S)> for &'a mut Vector2<S>
[src]

[src]

Performs the conversion.

impl<S: BaseFloat> InnerSpace for Vector2<S>
[src]

[src]

Vector dot (or inner) product.

[src]

Returns the angle between two vectors in radians.

[src]

Returns true if the vector is perpendicular (at right angles) to the other vector. Read more

[src]

Returns the squared magnitude. Read more

[src]

The distance from the tail to the tip of the vector.

[src]

Returns a vector with the same direction, but with a magnitude of 1.

[src]

Returns a vector with the same direction and a given magnitude.

[src]

Returns the result of linearly interpolating the magnitude of the vector towards the magnitude of other by the specified amount. Read more

[src]

Returns the vector projection of the current inner space projected onto the supplied argument. Read more

impl<S: Debug> Debug for Vector2<S>
[src]

[src]

Formats the value using the given formatter.