Struct cxx_qt_lib::QVector2D
source · #[repr(C)]pub struct QVector2D { /* private fields */ }
Expand description
The QVector2D class represents a vector or vertex in 2D space.
Implementations§
source§impl QVector2D
impl QVector2D
sourcepub fn length_squared(&self) -> f32
pub fn length_squared(&self) -> f32
Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.
source§impl QVector2D
impl QVector2D
sourcepub fn normalized(&self) -> QVector2D
pub fn normalized(&self) -> QVector2D
Returns the normalized unit vector form of this vector.
If this vector is null, then a null vector is returned. If the length of the vector is very close to 1, then the vector will be returned as-is. Otherwise the normalized form of the vector of length 1 will be returned.
source§impl QVector2D
impl QVector2D
sourcepub fn new(xpos: f32, ypos: f32) -> Self
pub fn new(xpos: f32, ypos: f32) -> Self
Constructs a vector with coordinates (xpos, ypos). Both coordinates must be finite.
sourcepub fn distance_to_line(&self, point: QVector2D, direction: QVector2D) -> f32
pub fn distance_to_line(&self, point: QVector2D, direction: QVector2D) -> f32
Returns the distance that this vertex is from a line defined by point and the unit vector direction.
If direction is a null vector, then it does not define a line. In that case, the distance from point to this vertex is returned.
sourcepub fn distance_to_point(&self, point: QVector2D) -> f32
pub fn distance_to_point(&self, point: QVector2D) -> f32
Returns the distance from this vertex to a point defined by the vertex point.