[−][src]Struct math2d::Vector2f
Mathematical vector on the 2D (x, y) plane.
Fields
x: f32Horizontal component.
y: f32Vertical 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 reciprocal(self) -> Self[src]
Component-wise reciprocal
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]
fn from(vec: Vector2f) -> 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 Vector2<f32>[src]
impl From<Vector2<f32>> for Vector2f[src]
impl From<Vec2> for Vector2f[src]
impl Clone for Vector2f[src]
fn clone(&self) -> 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.
fn add(self, rhs: Vector2f) -> Rectf[src]
impl<V> Add<V> for Vector2f where
V: Into<Vector2f>, [src]
V: Into<Vector2f>,
type Output = Vector2f
The resulting type after applying the + operator.
fn add(self, rhs: V) -> Vector2f[src]
impl Sub<Vector2f> for Rectf[src]
type Output = Rectf
The resulting type after applying the - operator.
fn sub(self, rhs: Vector2f) -> Rectf[src]
impl<V> Sub<V> for Vector2f where
V: Into<Vector2f>, [src]
V: Into<Vector2f>,
type Output = Vector2f
The resulting type after applying the - operator.
fn sub(self, rhs: V) -> Vector2f[src]
impl Mul<Matrix3x2f> for Vector2f[src]
type Output = Vector2f
The resulting type after applying the * operator.
fn mul(self, m: Matrix3x2f) -> Vector2f[src]
impl<V> Mul<V> for Vector2f where
V: Into<Vector2f>, [src]
V: Into<Vector2f>,
type Output = Vector2f
The resulting type after applying the * operator.
fn mul(self, rhs: V) -> Self[src]
impl Mul<Vector2f> for f32[src]
type Output = Vector2f
The resulting type after applying the * operator.
fn mul(self, rhs: Vector2f) -> Vector2f[src]
impl<V> Div<V> for Vector2f where
V: Into<Vector2f>, [src]
V: Into<Vector2f>,
type Output = Vector2f
The resulting type after applying the / operator.
fn div(self, rhs: V) -> Vector2f[src]
impl Div<Vector2f> for f32[src]
type Output = Vector2f
The resulting type after applying the / operator.
fn div(self, rhs: Vector2f) -> Vector2f[src]
impl Neg for Vector2f[src]
type Output = Vector2f
The resulting type after applying the - operator.
fn neg(self) -> Vector2f[src]
impl Serialize for Vector2f[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl<'de> Deserialize<'de> for Vector2f[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
impl<T> From for T[src]
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>, [src]
T: Deserialize<'de>,