[][src]Struct sfml::system::Vector2

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

Utility type for manipulating 2-dimensional vectors.

Vector2 is a simple type that defines a mathematical vector with two coordinates (x and y).

It can be used to represent anything that has two dimensions: a size, a point, a velocity, etc.

The type parameter T is the type of the coordinates.

You generally don't have to care about the generic form (Vector2<T>), the most common specializations have special type aliases:

The Vector2 type has a small and simple interface, its x and y members can be accessed directly (there are no accessors like set_x(), get_x()) and it contains no mathematical function like dot product, cross product, length, etc.

Usage example

let mut v1 = Vector2f::new(16.5, 24.0);
v1.x = 18.2;
let y = v1.y;

let v2 = v1 * 5.0;
let v3 = v1 + v2;
assert_ne!(v2, v3);

Note: for 3-dimensional vectors, see Vector3.

Fields

x: T

X coordinate of the vector.

y: T

Y coordinate of the vector.

Methods

impl<T> Vector2<T>[src]

pub fn new(x: T, y: T) -> Self[src]

Creates a new vector from its coordinates.

Trait Implementations

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

fn from(src: (T, T)) -> Self[src]

Constructs a Vector2 from (x, y).

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

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

impl<T: Default> Default for Vector2<T>[src]

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

impl<T: Ord> Ord for Vector2<T>[src]

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

impl<T: PartialOrd> PartialOrd<Vector2<T>> for Vector2<T>[src]

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

impl<T: Div + Copy> Div<T> for Vector2<T>[src]

type Output = Vector2<T::Output>

The resulting type after applying the / operator.

impl Div<Vector2<i32>> for i32[src]

type Output = Vector2<i32>

The resulting type after applying the / operator.

impl Div<Vector2<u32>> for u32[src]

type Output = Vector2<u32>

The resulting type after applying the / operator.

impl Div<Vector2<f32>> for f32[src]

type Output = Vector2<f32>

The resulting type after applying the / operator.

impl<T: Div> Div<Vector2<T>> for Vector2<T>[src]

type Output = Vector2<T::Output>

The resulting type after applying the / operator.

impl<T: Sub + Copy> Sub<T> for Vector2<T>[src]

type Output = Vector2<T::Output>

The resulting type after applying the - operator.

impl Sub<Vector2<i32>> for i32[src]

type Output = Vector2<i32>

The resulting type after applying the - operator.

impl Sub<Vector2<u32>> for u32[src]

type Output = Vector2<u32>

The resulting type after applying the - operator.

impl Sub<Vector2<f32>> for f32[src]

type Output = Vector2<f32>

The resulting type after applying the - operator.

impl<T: Sub> Sub<Vector2<T>> for Vector2<T>[src]

type Output = Vector2<T::Output>

The resulting type after applying the - operator.

impl<T: Add + Copy> Add<T> for Vector2<T>[src]

type Output = Vector2<T::Output>

The resulting type after applying the + operator.

impl Add<Vector2<i32>> for i32[src]

type Output = Vector2<i32>

The resulting type after applying the + operator.

impl Add<Vector2<u32>> for u32[src]

type Output = Vector2<u32>

The resulting type after applying the + operator.

impl Add<Vector2<f32>> for f32[src]

type Output = Vector2<f32>

The resulting type after applying the + operator.

impl<T: Add> Add<Vector2<T>> for Vector2<T>[src]

type Output = Vector2<T::Output>

The resulting type after applying the + operator.

impl<T: Mul + Copy> Mul<T> for Vector2<T>[src]

type Output = Vector2<T::Output>

The resulting type after applying the * operator.

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

type Output = Vector2<i32>

The resulting type after applying the * operator.

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

type Output = Vector2<u32>

The resulting type after applying the * operator.

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

type Output = Vector2<f32>

The resulting type after applying the * operator.

impl<T: Mul> Mul<Vector2<T>> for Vector2<T>[src]

type Output = Vector2<T::Output>

The resulting type after applying the * operator.

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

type Output = Self

The resulting type after applying the - operator.

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

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

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

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

Auto Trait Implementations

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

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

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

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

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

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, 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]