Expand description
Mathematical vector on the 2D (x, y) plane.
Fields§
§x: f32
Horizontal component.
y: f32
Vertical component.
Implementations§
source§impl Vector2f
impl Vector2f
sourcepub const UP: Vector2f = _
pub const UP: Vector2f = _
Up vector in the top-left coordinate system common to 2D drawing systems.
sourcepub const RIGHT: Vector2f = _
pub const RIGHT: Vector2f = _
Right vector in the top-left coordinate system common to 2D drawing systems.
sourcepub const DOWN: Vector2f = _
pub const DOWN: Vector2f = _
Down vector in the top-left coordinate system common to 2D drawing systems.
sourcepub const LEFT: Vector2f = _
pub const LEFT: Vector2f = _
Left vector in the top-left coordinate system common to 2D drawing systems.
sourcepub fn to_i32(self) -> Vector2i
pub fn to_i32(self) -> Vector2i
Converts the vector to unsigned integer values. Truncates integers, if you want your components to be rounded you must do this manually first.
sourcepub fn as_size(self) -> Sizef
pub fn as_size(self) -> Sizef
Converts this vector to a size value with the x representing width and the y representing height.
sourcepub fn rounded(self) -> Vector2f
pub fn rounded(self) -> Vector2f
Rounds the components of the vector to the nearest integer. Rounds half-way values away from 0.
sourcepub fn len_squared(self) -> f32
pub fn len_squared(self) -> f32
The squared length of the vector
sourcepub fn len(self) -> f32
pub fn len(self) -> f32
The length of the vector. This requires performing a square root, so the squared length should be preferred where possible.
sourcepub fn is_approx_eq(self, other: impl Into<Vector2f>, epsilon: f32) -> bool
pub fn is_approx_eq(self, other: impl Into<Vector2f>, epsilon: f32) -> bool
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.