Struct sfml::system::Vector2
[−]
[src]
#[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:
Vector2<f32>
isVector2f
Vector2<i32>
isVector2i
Vector2<u32>
isVector2u
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]
Trait Implementations
impl<T: Clone> Clone for Vector2<T>
[src]
fn clone(&self) -> Vector2<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: PartialOrd> PartialOrd for Vector2<T>
[src]
fn partial_cmp(&self, __arg_0: &Vector2<T>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Vector2<T>) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Vector2<T>) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Vector2<T>) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Vector2<T>) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Ord> Ord for Vector2<T>
[src]
fn cmp(&self, __arg_0: &Vector2<T>) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl<T: PartialEq> PartialEq for Vector2<T>
[src]
fn eq(&self, __arg_0: &Vector2<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Vector2<T>) -> bool
[src]
This method tests for !=
.
impl<T: Eq> Eq for Vector2<T>
[src]
impl<T: Debug> Debug for Vector2<T>
[src]
impl<T: Copy> Copy for Vector2<T>
[src]
impl<T: Default> Default for Vector2<T>
[src]
impl<T> From<(T, T)> for Vector2<T>
[src]
impl<T: Add + Copy> Add<T> for Vector2<T>
[src]
type Output = Vector2<T::Output>
The resulting type after applying the +
operator.
fn add(self, rhs: T) -> Vector2<T::Output>
[src]
Performs the +
operation.
impl<T: Sub + Copy> Sub<T> for Vector2<T>
[src]
type Output = Vector2<T::Output>
The resulting type after applying the -
operator.
fn sub(self, rhs: T) -> Vector2<T::Output>
[src]
Performs the -
operation.
impl<T: Mul + Copy> Mul<T> for Vector2<T>
[src]
type Output = Vector2<T::Output>
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> Vector2<T::Output>
[src]
Performs the *
operation.
impl<T: Div + Copy> Div<T> for Vector2<T>
[src]
type Output = Vector2<T::Output>
The resulting type after applying the /
operator.
fn div(self, rhs: T) -> Vector2<T::Output>
[src]
Performs the /
operation.
impl<T: Add> Add for Vector2<T>
[src]
type Output = Vector2<T::Output>
The resulting type after applying the +
operator.
fn add(self, rhs: Vector2<T>) -> Vector2<T::Output>
[src]
Performs the +
operation.
impl<T: AddAssign> AddAssign for Vector2<T>
[src]
fn add_assign(&mut self, rhs: Self)
[src]
Performs the +=
operation.
impl<T: Sub> Sub for Vector2<T>
[src]
type Output = Vector2<T::Output>
The resulting type after applying the -
operator.
fn sub(self, rhs: Vector2<T>) -> Vector2<T::Output>
[src]
Performs the -
operation.
impl<T: SubAssign> SubAssign for Vector2<T>
[src]
fn sub_assign(&mut self, rhs: Self)
[src]
Performs the -=
operation.
impl<T: Mul> Mul for Vector2<T>
[src]
type Output = Vector2<T::Output>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vector2<T>) -> Vector2<T::Output>
[src]
Performs the *
operation.
impl<T: MulAssign + Copy> MulAssign<T> for Vector2<T>
[src]
fn mul_assign(&mut self, rhs: T)
[src]
Performs the *=
operation.
impl<T: Div> Div for Vector2<T>
[src]
type Output = Vector2<T::Output>
The resulting type after applying the /
operator.
fn div(self, rhs: Vector2<T>) -> Vector2<T::Output>
[src]
Performs the /
operation.
impl<T: DivAssign + Copy> DivAssign<T> for Vector2<T>
[src]
fn div_assign(&mut self, rhs: T)
[src]
Performs the /=
operation.