[][src]Struct math2d::Vector2f

#[repr(C)]
pub struct Vector2f { pub x: f32, pub y: f32, }

Mathematical vector on the 2D (x, y) plane.

Fields

x: f32

Horizontal component.

y: f32

Vertical component.

Methods

impl Vector2f[src]

pub const ZERO: Vector2f[src]

Zero vector, addition identity value.

pub const ONE: Vector2f[src]

One vector, multiplication identity value.

pub const UP: Vector2f[src]

Up vector in the top-left coordinate system common to 2D drawing systems.

pub const RIGHT: Vector2f[src]

Right vector in the top-left coordinate system common to 2D drawing systems.

pub const DOWN: Vector2f[src]

Down vector in the top-left coordinate system common to 2D drawing systems.

pub const LEFT: Vector2f[src]

Left vector in the top-left coordinate system common to 2D drawing systems.

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

Construct a vector from the components.

pub fn to_i32(self) -> Vector2i[src]

Converts the vector to unsigned integer values. Truncates integers, if you want your components to be rounded you must do this manually first.

pub fn to_point(self) -> Point2f[src]

pub fn to_size(self) -> Sizef[src]

Converts this vector to a size value with the x representing width and the y representing height.

pub fn rounded(self) -> Vector2f[src]

Rounds the components of the vector to the nearest integer. Rounds half-way values away from 0.

pub fn dot(self, rhs: Vector2f) -> f32[src]

Dot product of two vectors.

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

The squared length of the vector

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

The length of the vector. This requires performing a square root, so the squared length should be preferred where possible.

pub fn abs(self) -> Self[src]

Absolute value of the vector components.

pub fn is_approx_eq(self, other: impl Into<Vector2f>, epsilon: f32) -> bool[src]

Tests if two vectors are approximately equal to each other within a given epsilon. The epsilon is applied component-wise. If you would like to check that two vectors are within a specified distance of each other, you should subtract one from the other and check the length of the resulting distance vector between them.

Trait Implementations

impl Copy for Vector2f[src]

impl PartialEq<Vector2f> for Vector2f[src]

impl Default for Vector2f[src]

impl From<Vector2f> for Thicknessf[src]

impl From<f32> for Vector2f[src]

impl From<[f32; 2]> for Vector2f[src]

impl From<Vector2f> for [f32; 2][src]

impl From<Vector2f> for D2D_VECTOR_2F[src]

impl From<D2D_VECTOR_2F> for Vector2f[src]

impl From<Vector2f> for Vector2<f32>[src]

impl From<Vector2<f32>> for Vector2f[src]

impl From<Vec2> for Vector2f[src]

impl Clone for Vector2f[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Vector2f[src]

impl Add<Vector2f> for Rectf[src]

type Output = Rectf

The resulting type after applying the + operator.

impl<V> Add<V> for Vector2f where
    V: Into<Vector2f>, 
[src]

type Output = Vector2f

The resulting type after applying the + operator.

impl Sub<Vector2f> for Rectf[src]

type Output = Rectf

The resulting type after applying the - operator.

impl<V> Sub<V> for Vector2f where
    V: Into<Vector2f>, 
[src]

type Output = Vector2f

The resulting type after applying the - operator.

impl Mul<Matrix3x2f> for Vector2f[src]

type Output = Vector2f

The resulting type after applying the * operator.

impl<V> Mul<V> for Vector2f where
    V: Into<Vector2f>, 
[src]

type Output = Vector2f

The resulting type after applying the * operator.

impl Mul<Vector2f> for f32[src]

type Output = Vector2f

The resulting type after applying the * operator.

impl Div<f32> for Vector2f[src]

type Output = Vector2f

The resulting type after applying the / operator.

impl Div<Vector2f> for f32[src]

type Output = Vector2f

The resulting type after applying the / operator.

impl Neg for Vector2f[src]

type Output = Vector2f

The resulting type after applying the - operator.

impl Serialize for Vector2f[src]

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

Auto Trait Implementations

impl Send for Vector2f

impl Sync for Vector2f

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

impl<T, U> TryInto 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> Any for T where
    T: 'static + ?Sized
[src]

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