#[repr(C)]pub struct QVector2D { /* private fields */ }
Expand description
The QVector2D class represents a vector or vertex in 2D space.
C++ class: QVector2D
.
Implementations§
source§impl QVector2D
impl QVector2D
sourcepub unsafe fn add_assign(
&self,
vector: impl CastInto<Ref<QVector2D>>
) -> Ref<QVector2D>
pub unsafe fn add_assign( &self, vector: impl CastInto<Ref<QVector2D>> ) -> Ref<QVector2D>
Adds the given vector to this vector and returns a reference to this vector.
Calls C++ function: QVector2D& QVector2D::operator+=(const QVector2D& vector)
.
Adds the given vector to this vector and returns a reference to this vector.
See also operator-=().
sourcepub unsafe fn copy_from(
&self,
other: impl CastInto<Ref<QVector2D>>
) -> Ref<QVector2D>
pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QVector2D>> ) -> Ref<QVector2D>
The QVector2D class represents a vector or vertex in 2D space.
Calls C++ function: QVector2D& QVector2D::operator=(const QVector2D& other)
.
sourcepub unsafe fn distance_to_line(
&self,
point: impl CastInto<Ref<QVector2D>>,
direction: impl CastInto<Ref<QVector2D>>
) -> c_float
pub unsafe fn distance_to_line( &self, point: impl CastInto<Ref<QVector2D>>, direction: impl CastInto<Ref<QVector2D>> ) -> c_float
Returns the distance that this vertex is from a line defined by point and the unit vector direction.
Calls C++ function: float QVector2D::distanceToLine(const QVector2D& point, const QVector2D& direction) const
.
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.
This function was introduced in Qt 5.1.
See also distanceToPoint().
sourcepub unsafe fn distance_to_point(
&self,
point: impl CastInto<Ref<QVector2D>>
) -> c_float
pub unsafe fn distance_to_point( &self, point: impl CastInto<Ref<QVector2D>> ) -> c_float
Returns the distance from this vertex to a point defined by the vertex point.
Calls C++ function: float QVector2D::distanceToPoint(const QVector2D& point) const
.
Returns the distance from this vertex to a point defined by the vertex point.
This function was introduced in Qt 5.1.
See also distanceToLine().
sourcepub unsafe fn div_assign_float(&self, divisor: c_float) -> Ref<QVector2D>
pub unsafe fn div_assign_float(&self, divisor: c_float) -> Ref<QVector2D>
Divides this vector's coordinates by the given divisor, and returns a reference to this vector.
Calls C++ function: QVector2D& QVector2D::operator/=(float divisor)
.
Divides this vector’s coordinates by the given divisor, and returns a reference to this vector.
See also operator*=().
sourcepub unsafe fn div_assign_q_vector_2d(
&self,
vector: impl CastInto<Ref<QVector2D>>
) -> Ref<QVector2D>
pub unsafe fn div_assign_q_vector_2d( &self, vector: impl CastInto<Ref<QVector2D>> ) -> Ref<QVector2D>
Divides the components of this vector by the corresponding components in vector.
Calls C++ function: QVector2D& QVector2D::operator/=(const QVector2D& vector)
.
Divides the components of this vector by the corresponding components in vector.
This function was introduced in Qt 5.5.
See also operator*=().
sourcepub unsafe fn dot_product(
v1: impl CastInto<Ref<QVector2D>>,
v2: impl CastInto<Ref<QVector2D>>
) -> c_float
pub unsafe fn dot_product( v1: impl CastInto<Ref<QVector2D>>, v2: impl CastInto<Ref<QVector2D>> ) -> c_float
Returns the dot product of v1 and v2.
Calls C++ function: static float QVector2D::dotProduct(const QVector2D& v1, const QVector2D& v2)
.
Returns the dot product of v1 and v2.
sourcepub unsafe fn index_mut(&self, i: c_int) -> *mut c_float
pub unsafe fn index_mut(&self, i: c_int) -> *mut c_float
Returns the component of the vector at index position i as a modifiable reference.
Calls C++ function: float& QVector2D::operator[](int i)
.
Returns the component of the vector at index position i as a modifiable reference.
i must be a valid index position in the vector (i.e., 0 <= i < 2).
This function was introduced in Qt 5.2.
sourcepub unsafe fn index(&self, i: c_int) -> c_float
pub unsafe fn index(&self, i: c_int) -> c_float
Returns the component of the vector at index position i.
Calls C++ function: float QVector2D::operator[](int i) const
.
Returns the component of the vector at index position i.
i must be a valid index position in the vector (i.e., 0 <= i < 2).
This function was introduced in Qt 5.2.
sourcepub unsafe fn is_null(&self) -> bool
pub unsafe fn is_null(&self) -> bool
Returns true
if the x and y coordinates are set to 0.0, otherwise returns false
.
Calls C++ function: bool QVector2D::isNull() const
.
Returns true
if the x and y coordinates are set to 0.0, otherwise returns false
.
sourcepub unsafe fn length(&self) -> c_float
pub unsafe fn length(&self) -> c_float
Returns the length of the vector from the origin.
Calls C++ function: float QVector2D::length() const
.
Returns the length of the vector from the origin.
See also lengthSquared() and normalized().
sourcepub unsafe fn length_squared(&self) -> c_float
pub unsafe fn length_squared(&self) -> c_float
Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.
Calls C++ function: float QVector2D::lengthSquared() const
.
Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.
See also length() and dotProduct().
sourcepub unsafe fn mul_assign_float(&self, factor: c_float) -> Ref<QVector2D>
pub unsafe fn mul_assign_float(&self, factor: c_float) -> Ref<QVector2D>
Multiplies this vector's coordinates by the given factor, and returns a reference to this vector.
Calls C++ function: QVector2D& QVector2D::operator*=(float factor)
.
Multiplies this vector’s coordinates by the given factor, and returns a reference to this vector.
See also operator/=().
sourcepub unsafe fn mul_assign_q_vector_2d(
&self,
vector: impl CastInto<Ref<QVector2D>>
) -> Ref<QVector2D>
pub unsafe fn mul_assign_q_vector_2d( &self, vector: impl CastInto<Ref<QVector2D>> ) -> Ref<QVector2D>
Multiplies the components of this vector by the corresponding components in vector.
Calls C++ function: QVector2D& QVector2D::operator*=(const QVector2D& vector)
.
Multiplies the components of this vector by the corresponding components in vector.
sourcepub unsafe fn neg(&self) -> CppBox<QVector2D>
pub unsafe fn neg(&self) -> CppBox<QVector2D>
Calls C++ function: QVector2D operator-(const QVector2D& vector)
.
sourcepub unsafe fn new() -> CppBox<QVector2D>
pub unsafe fn new() -> CppBox<QVector2D>
Constructs a null vector, i.e. with coordinates (0, 0).
Calls C++ function: [constructor] void QVector2D::QVector2D()
.
Constructs a null vector, i.e. with coordinates (0, 0).
sourcepub unsafe fn from_2_float(xpos: c_float, ypos: c_float) -> CppBox<QVector2D>
pub unsafe fn from_2_float(xpos: c_float, ypos: c_float) -> CppBox<QVector2D>
Constructs a vector with coordinates (xpos, ypos).
Calls C++ function: [constructor] void QVector2D::QVector2D(float xpos, float ypos)
.
Constructs a vector with coordinates (xpos, ypos).
sourcepub unsafe fn from_q_point(
point: impl CastInto<Ref<QPoint>>
) -> CppBox<QVector2D>
pub unsafe fn from_q_point( point: impl CastInto<Ref<QPoint>> ) -> CppBox<QVector2D>
Constructs a vector with x and y coordinates from a 2D point.
Calls C++ function: [constructor] void QVector2D::QVector2D(const QPoint& point)
.
Constructs a vector with x and y coordinates from a 2D point.
sourcepub unsafe fn from_q_point_f(
point: impl CastInto<Ref<QPointF>>
) -> CppBox<QVector2D>
pub unsafe fn from_q_point_f( point: impl CastInto<Ref<QPointF>> ) -> CppBox<QVector2D>
Constructs a vector with x and y coordinates from a 2D point.
Calls C++ function: [constructor] void QVector2D::QVector2D(const QPointF& point)
.
Constructs a vector with x and y coordinates from a 2D point.
sourcepub unsafe fn from_q_vector_3d(
vector: impl CastInto<Ref<QVector3D>>
) -> CppBox<QVector2D>
pub unsafe fn from_q_vector_3d( vector: impl CastInto<Ref<QVector3D>> ) -> CppBox<QVector2D>
Constructs a vector with x and y coordinates from a 3D vector. The z coordinate of vector is dropped.
Calls C++ function: [constructor] void QVector2D::QVector2D(const QVector3D& vector)
.
Constructs a vector with x and y coordinates from a 3D vector. The z coordinate of vector is dropped.
See also toVector3D().
sourcepub unsafe fn from_q_vector_4d(
vector: impl CastInto<Ref<QVector4D>>
) -> CppBox<QVector2D>
pub unsafe fn from_q_vector_4d( vector: impl CastInto<Ref<QVector4D>> ) -> CppBox<QVector2D>
Constructs a vector with x and y coordinates from a 3D vector. The z and w coordinates of vector are dropped.
Calls C++ function: [constructor] void QVector2D::QVector2D(const QVector4D& vector)
.
Constructs a vector with x and y coordinates from a 3D vector. The z and w coordinates of vector are dropped.
See also toVector4D().
sourcepub unsafe fn new_copy(
other: impl CastInto<Ref<QVector2D>>
) -> CppBox<QVector2D>
pub unsafe fn new_copy( other: impl CastInto<Ref<QVector2D>> ) -> CppBox<QVector2D>
The QVector2D class represents a vector or vertex in 2D space.
Calls C++ function: [constructor] void QVector2D::QVector2D(const QVector2D& other)
.
sourcepub unsafe fn normalize(&self)
pub unsafe fn normalize(&self)
Normalizes the currect vector in place. Nothing happens if this vector is a null vector or the length of the vector is very close to 1.
Calls C++ function: void QVector2D::normalize()
.
Normalizes the currect vector in place. Nothing happens if this vector is a null vector or the length of the vector is very close to 1.
See also length() and normalized().
sourcepub unsafe fn normalized(&self) -> CppBox<QVector2D>
pub unsafe fn normalized(&self) -> CppBox<QVector2D>
Returns the normalized unit vector form of this vector.
Calls C++ function: QVector2D QVector2D::normalized() const
.
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.
sourcepub unsafe fn set_x(&self, x: c_float)
pub unsafe fn set_x(&self, x: c_float)
Sets the x coordinate of this point to the given x coordinate.
Calls C++ function: void QVector2D::setX(float x)
.
sourcepub unsafe fn set_y(&self, y: c_float)
pub unsafe fn set_y(&self, y: c_float)
Sets the y coordinate of this point to the given y coordinate.
Calls C++ function: void QVector2D::setY(float y)
.
sourcepub unsafe fn sub_assign(
&self,
vector: impl CastInto<Ref<QVector2D>>
) -> Ref<QVector2D>
pub unsafe fn sub_assign( &self, vector: impl CastInto<Ref<QVector2D>> ) -> Ref<QVector2D>
Subtracts the given vector from this vector and returns a reference to this vector.
Calls C++ function: QVector2D& QVector2D::operator-=(const QVector2D& vector)
.
Subtracts the given vector from this vector and returns a reference to this vector.
See also operator+=().
sourcepub unsafe fn to_point(&self) -> CppBox<QPoint>
pub unsafe fn to_point(&self) -> CppBox<QPoint>
Returns the QPoint form of this 2D vector.
Calls C++ function: QPoint QVector2D::toPoint() const
.
Returns the QPoint form of this 2D vector.
See also toPointF() and toVector3D().
sourcepub unsafe fn to_point_f(&self) -> CppBox<QPointF>
pub unsafe fn to_point_f(&self) -> CppBox<QPointF>
Returns the QPointF form of this 2D vector.
Calls C++ function: QPointF QVector2D::toPointF() const
.
Returns the QPointF form of this 2D vector.
See also toPoint() and toVector3D().
sourcepub unsafe fn to_q_variant(&self) -> CppBox<QVariant>
pub unsafe fn to_q_variant(&self) -> CppBox<QVariant>
sourcepub unsafe fn to_vector_3d(&self) -> CppBox<QVector3D>
pub unsafe fn to_vector_3d(&self) -> CppBox<QVector3D>
Returns the 3D form of this 2D vector, with the z coordinate set to zero.
Calls C++ function: QVector3D QVector2D::toVector3D() const
.
Returns the 3D form of this 2D vector, with the z coordinate set to zero.
See also toVector4D() and toPoint().
sourcepub unsafe fn to_vector_4d(&self) -> CppBox<QVector4D>
pub unsafe fn to_vector_4d(&self) -> CppBox<QVector4D>
Returns the 4D form of this 2D vector, with the z and w coordinates set to zero.
Calls C++ function: QVector4D QVector2D::toVector4D() const
.
Returns the 4D form of this 2D vector, with the z and w coordinates set to zero.
See also toVector3D() and toPoint().
Trait Implementations§
source§impl CppDeletable for QVector2D
impl CppDeletable for QVector2D
source§impl PartialEq<Ref<QVector2D>> for QVector2D
impl PartialEq<Ref<QVector2D>> for QVector2D
source§fn eq(&self, v2: &Ref<QVector2D>) -> bool
fn eq(&self, v2: &Ref<QVector2D>) -> bool
Returns true
if page layout lhs is equal to page layout rhs, i.e. if all the attributes are exactly equal.
Calls C++ function: bool operator==(const QVector2D& v1, const QVector2D& v2)
.
Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(const QPageLayout &lhs, const QPageLayout &rhs)
:
Returns true
if page layout lhs is equal to page layout rhs, i.e. if all the attributes are exactly equal.
Note that this is a strict equality, especially for page size where the QPageSize ID, name and size must exactly match, and the margins where the units must match.
See also QPageLayout::isEquivalentTo().