#[repr(C)]pub struct Vector2f {
pub x: f32,
pub y: f32,
}
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.