8#include <QtGui/qtguiglobal.h>
9#include <QtCore/qpoint.h>
10#include <QtCore/qrect.h>
11#include <QtCore/qmath.h>
13#include <QtCore/q20type_traits.h>
14#include <QtCore/q23utility.h>
35 constexpr QVector2D(
float xpos,
float ypos)
noexcept;
45 constexpr bool isNull() const noexcept;
47 constexpr
float x() const noexcept;
48 constexpr
float y() const noexcept;
50 constexpr
void setX(
float x) noexcept;
51 constexpr
void setY(
float y) noexcept;
53 constexpr
float &operator[](
int i);
54 constexpr
float operator[](
int i) const;
56 [[nodiscard]]
float length() const noexcept;
67 constexpr
QVector2D &operator*=(
float factor) noexcept;
78 return v1.v[0] ==
v2.v[0] &&
v1.v[1] ==
v2.v[1];
83 return v1.v[0] !=
v2.v[0] ||
v1.v[1] !=
v2.v[1];
119 Q_ASSERT(divisor < 0 || divisor > 0);
132#ifndef QT_NO_VECTOR3D
135#ifndef QT_NO_VECTOR4D
142 Q_GUI_EXPORT operator
QVariant() const;
150 template <
std::
size_t I,
152 std::enable_if_t<(I < 2),
bool> = true,
154 friend constexpr decltype(auto)
get(V &&vec) noexcept
156 return q23::forward_like<V>(vec.v[I]);
168#ifndef QT_NO_VECTOR3D
175 constexpr QVector3D(
float xpos,
float ypos,
float zpos) noexcept :
v{xpos, ypos, zpos} {}
179#ifndef QT_NO_VECTOR2D
183#ifndef QT_NO_VECTOR4D
187 constexpr bool isNull() const noexcept;
189 constexpr
float x() const noexcept;
190 constexpr
float y() const noexcept;
191 constexpr
float z() const noexcept;
193 constexpr
void setX(
float x) noexcept;
194 constexpr
void setY(
float y) noexcept;
195 constexpr
void setZ(
float z) noexcept;
197 constexpr
float &operator[](
int i);
198 constexpr
float operator[](
int i) const;
200 [[nodiscard]]
float length() const noexcept;
201 [[nodiscard]] constexpr
float lengthSquared() const noexcept;
208 constexpr
QVector3D &operator*=(
float factor) noexcept;
226 return v1.v[0] ==
v2.v[0] &&
v1.v[1] ==
v2.v[1] &&
v1.v[2] ==
v2.v[2];
231 return v1.v[0] !=
v2.v[0] ||
v1.v[1] !=
v2.v[1] ||
v1.v[2] !=
v2.v[2];
272 Q_ASSERT(divisor < 0 || divisor > 0);
287#ifndef QT_NO_VECTOR2D
290#ifndef QT_NO_VECTOR4D
297 Q_GUI_EXPORT operator
QVariant() const;
304#ifndef QT_NO_MATRIX4X4
309 template <std::size_t I,
311 std::enable_if_t<(I < 3), bool> =
true,
312 std::enable_if_t<std::is_same_v<q20::remove_cvref_t<V>,
QVector3D>,
bool> =
true>
313 friend constexpr decltype(
auto)
get(V &&vec)
noexcept
315 return q23::forward_like<V>(vec.v[I]);
327#ifndef QT_NO_VECTOR4D
334 constexpr QVector4D(
float xpos,
float ypos,
float zpos,
float wpos)
noexcept;
337#ifndef QT_NO_VECTOR2D
341#ifndef QT_NO_VECTOR3D
346 constexpr bool isNull() const noexcept;
348 constexpr
float x() const noexcept;
349 constexpr
float y() const noexcept;
350 constexpr
float z() const noexcept;
351 constexpr
float w() const noexcept;
353 constexpr
void setX(
float x) noexcept;
354 constexpr
void setY(
float y) noexcept;
355 constexpr
void setZ(
float z) noexcept;
356 constexpr
void setW(
float w) noexcept;
358 constexpr
float &operator[](
int i);
359 constexpr
float operator[](
int i) const;
361 [[nodiscard]]
float length() const noexcept;
362 [[nodiscard]] constexpr
float lengthSquared() const noexcept;
369 constexpr
QVector4D &operator*=(
float factor) noexcept;
380 return v1.v[0] ==
v2.v[0] &&
v1.v[1] ==
v2.v[1] &&
v1.v[2] ==
v2.v[2] &&
v1.v[3] ==
v2.v[3];
385 return v1.v[0] !=
v2.v[0] ||
v1.v[1] !=
v2.v[1] ||
v1.v[2] !=
v2.v[2] ||
v1.v[3] !=
v2.v[3];
420 Q_ASSERT(divisor < 0 || divisor > 0);
436#ifndef QT_NO_VECTOR2D
440#ifndef QT_NO_VECTOR3D
448 Q_GUI_EXPORT operator
QVariant() const;
456#ifndef QT_NO_MATRIX4X4
461 template <std::size_t I,
463 std::enable_if_t<(I < 4), bool> =
true,
464 std::enable_if_t<std::is_same_v<q20::remove_cvref_t<V>,
QVector4D>,
bool> =
true>
465 friend constexpr decltype(
auto)
get(V &&vec)
noexcept
467 return q23::forward_like<V>(vec.v[I]);
479#ifndef QT_NO_VECTOR2D
489#ifndef QT_NO_VECTOR3D
492#ifndef QT_NO_VECTOR4D
526 return v[0] *
v[0] +
v[1] *
v[1];
548 return (*
this - point).length();
554 return (*
this - point).length();
556 return (*
this -
p).length();
589 Q_ASSERT(divisor < 0 || divisor > 0);
606 return v1.v[0] *
v2.v[0] +
v1.v[1] *
v2.v[1];
609#ifndef QT_NO_VECTOR3D
615#ifndef QT_NO_VECTOR4D
633#ifndef QT_NO_DEBUG_STREAM
637#ifndef QT_NO_DATASTREAM
648#ifndef QT_NO_VECTOR3D
656#ifndef QT_NO_VECTOR2D
661#ifndef QT_NO_VECTOR4D
715 return v[0] *
v[0] +
v[1] *
v[1] +
v[2] *
v[2];
752 Q_ASSERT(divisor < 0 || divisor > 0);
772 return v1.v[0] *
v2.v[0] +
v1.v[1] *
v2.v[1] +
v1.v[2] *
v2.v[2];
778 v1.v[2] *
v2.v[0] -
v1.v[0] *
v2.v[2],
779 v1.v[0] *
v2.v[1] -
v1.v[1] *
v2.v[0]);
794 return (*
this - point).length();
804 QVector3D n = normal(plane2 - plane1, plane3 - plane1);
811 return (*
this - point).length();
813 return (*
this -
p).length();
816#ifndef QT_NO_VECTOR2D
822#ifndef QT_NO_VECTOR4D
839#ifndef QT_NO_DEBUG_STREAM
843#ifndef QT_NO_DATASTREAM
854#ifndef QT_NO_VECTOR4D
858constexpr inline QVector4D::QVector4D(
float xpos,
float ypos,
float zpos,
float wpos) noexcept :
v{xpos, ypos, zpos, wpos} {}
864#ifndef QT_NO_VECTOR2D
868#ifndef QT_NO_VECTOR3D
907 return v[0] *
v[0] +
v[1] *
v[1] +
v[2] *
v[2] +
v[3] *
v[3];
967 Q_ASSERT(divisor < 0 || divisor > 0);
990 return v1.v[0] *
v2.v[0] +
v1.v[1] *
v2.v[1] +
v1.v[2] *
v2.v[2] +
v1.v[3] *
v2.v[3];
993#ifndef QT_NO_VECTOR2D
1009#ifndef QT_NO_VECTOR3D
1035#ifndef QT_NO_DEBUG_STREAM
1039#ifndef QT_NO_DATASTREAM
1052#ifndef QT_NO_VECTOR2D
1061#ifndef QT_NO_VECTOR3D
1072#ifndef QT_NO_VECTOR4D
\inmodule QtCore\reentrant
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QVector2D class represents a vector or vertex in 2D space.
float length() const noexcept
Returns the length of the vector from the origin.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float & operator[](int i)
QVector2D normalized() const noexcept
Returns the normalized unit vector form of this vector.
constexpr friend QVector2D operator-(QVector2D v1, QVector2D v2) noexcept
//! friend
constexpr float lengthSquared() const noexcept
Returns the squared length of the vector from the origin.
constexpr friend QVector2D operator*(QVector2D v1, QVector2D v2) noexcept
//! friend
constexpr friend bool operator!=(QVector2D v1, QVector2D v2) noexcept
Returns true if v1 is not equal to v2; otherwise returns false.
constexpr QVector3D toVector3D() const noexcept
Returns the 3D form of this 2D vector, with the z coordinate set to zero.
friend constexpr decltype(auto) get(V &&vec) noexcept
constexpr friend QVector2D operator/(QVector2D vector, QVector2D divisor)
//! friend
constexpr QVector2D & operator*=(float factor) noexcept
Multiplies this vector's coordinates by the given finite factor and returns a reference to this vecto...
constexpr QVector2D & operator+=(QVector2D vector) noexcept
Adds the given vector to this vector and returns a reference to this vector.
constexpr float x() const noexcept
Returns the x coordinate of this point.
friend Q_GUI_EXPORT bool qFuzzyCompare(QVector2D v1, QVector2D v2) noexcept
//! friend
static constexpr float dotProduct(QVector2D v1, QVector2D v2) noexcept
Returns the dot product of v1 and v2.
constexpr QVector2D & operator/=(float divisor)
Divides this vector's coordinates by the given divisor and returns a reference to this vector.
float distanceToPoint(QVector2D point) const noexcept
constexpr QVector2D() noexcept
Constructs a null vector, i.e.
constexpr QVector2D & operator-=(QVector2D vector) noexcept
Subtracts the given vector from this vector and returns a reference to this vector.
constexpr friend QVector2D operator/(QVector2D vector, float divisor)
//! friend
constexpr void setY(float y) noexcept
Sets the y coordinate of this point to the given finite y coordinate.
constexpr friend QVector2D operator-(QVector2D vector) noexcept
//! friendThis is an overloaded member function, provided for convenience. It differs from the above ...
constexpr QPointF toPointF() const noexcept
Returns the QPointF form of this 2D vector.
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
constexpr friend QVector2D operator*(float factor, QVector2D vector) noexcept
//! friend
constexpr friend QVector2D operator*(QVector2D vector, float factor) noexcept
//! friend
constexpr QPoint toPoint() const noexcept
Returns the QPoint form of this 2D vector.
constexpr QVector4D toVector4D() const noexcept
Returns the 4D form of this 2D vector, with the z and w coordinates set to zero.
void normalize() noexcept
Normalizes the current vector in place.
float distanceToLine(QVector2D point, QVector2D direction) const noexcept
QVector2D(Qt::Initialization) noexcept
constexpr bool isNull() const noexcept
Returns true if the x and y coordinates are set to 0.0, otherwise returns false.
QT_WARNING_POP constexpr friend QVector2D operator+(QVector2D v1, QVector2D v2) noexcept
//! friend
The QVector3D class represents a vector or vertex in 3D space.
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
float distanceToLine(QVector3D point, QVector3D direction) const noexcept
Returns the distance that this vertex is from a line defined by point and the unit vector direction.
constexpr bool isNull() const noexcept
Returns true if the x, y, and z coordinates are set to 0.0, otherwise returns false.
constexpr QVector3D & operator*=(float factor) noexcept
Multiplies this vector's coordinates by the given finite factor and returns a reference to this vecto...
constexpr float distanceToPlane(QVector3D plane, QVector3D normal) const noexcept
Returns the distance from this vertex to a plane defined by the vertex plane and a normal unit vector...
constexpr friend bool operator!=(QVector3D v1, QVector3D v2) noexcept
Returns true if v1 is not equal to v2; otherwise returns false.
static QVector3D normal(QVector3D v1, QVector3D v2) noexcept
Returns the unit normal vector of a plane spanned by vectors v1 and v2, which must not be parallel to...
float length() const noexcept
Returns the length of the vector from the origin.
constexpr friend QVector3D operator/(QVector3D vector, float divisor)
//! friend
QVector3D normalized() const noexcept
Returns the normalized unit vector form of this vector.
constexpr float lengthSquared() const noexcept
Returns the squared length of the vector from the origin.
constexpr friend QVector3D operator*(float factor, QVector3D vector) noexcept
//! friend
constexpr void setY(float y) noexcept
Sets the y coordinate of this point to the given finite y coordinate.
QT_WARNING_POP float distanceToPoint(QVector3D point) const noexcept
constexpr friend QVector3D operator/(QVector3D vector, QVector3D divisor)
//! friend
Q_GUI_EXPORT QVector3D project(const QMatrix4x4 &modelView, const QMatrix4x4 &projection, const QRect &viewport) const
friend QVector3D operator*(const QVector3D &vector, const QMatrix4x4 &matrix)
constexpr friend QVector3D operator*(QVector3D v1, QVector3D v2) noexcept
//! friend
friend constexpr decltype(auto) get(V &&vec) noexcept
constexpr float & operator[](int i)
constexpr QPoint toPoint() const noexcept
Returns the QPoint form of this 3D vector.
constexpr QPointF toPointF() const noexcept
Returns the QPointF form of this 3D vector.
friend Q_GUI_EXPORT bool qFuzzyCompare(QVector3D v1, QVector3D v2) noexcept
//! friend
constexpr friend QVector3D operator-(QVector3D v1, QVector3D v2) noexcept
//! friend
constexpr QVector3D & operator-=(QVector3D vector) noexcept
Subtracts the given vector from this vector and returns a reference to this vector.
constexpr friend QVector3D operator*(QVector3D vector, float factor) noexcept
//! friend
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr QVector2D toVector2D() const noexcept
Returns the 2D vector form of this 3D vector, dropping the z coordinate.
constexpr QVector4D toVector4D() const noexcept
Returns the 4D form of this 3D vector, with the w coordinate set to zero.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr void setZ(float z) noexcept
Sets the z coordinate of this point to the given finite z coordinate.
friend QVector3D operator*(const QMatrix4x4 &matrix, const QVector3D &vector)
constexpr QVector3D & operator/=(float divisor)
Divides this vector's coordinates by the given divisor, and returns a reference to this vector.
static constexpr float dotProduct(QVector3D v1, QVector3D v2) noexcept
Returns the dot product of v1 and v2.
constexpr QVector3D(float xpos, float ypos, float zpos) noexcept
Constructs a vector with coordinates (xpos, ypos, zpos).
constexpr QVector3D() noexcept
Constructs a null vector, i.e.
constexpr QVector3D & operator+=(QVector3D vector) noexcept
Adds the given vector to this vector and returns a reference to this vector.
static constexpr QVector3D crossProduct(QVector3D v1, QVector3D v2) noexcept
Returns the cross-product of vectors v1 and v2, which is normal to the plane spanned by v1 and v2.
constexpr friend QVector3D operator+(QVector3D v1, QVector3D v2) noexcept
//! friend
void normalize() noexcept
Normalizes the current vector in place.
QVector3D(Qt::Initialization) noexcept
Q_GUI_EXPORT QVector3D unproject(const QMatrix4x4 &modelView, const QMatrix4x4 &projection, const QRect &viewport) const
constexpr float z() const noexcept
Returns the z coordinate of this point.
constexpr friend QVector3D operator-(QVector3D vector) noexcept
//! friendThis is an overloaded member function, provided for convenience. It differs from the above ...
The QVector4D class represents a vector or vertex in 4D space.
constexpr QVector4D & operator-=(QVector4D vector) noexcept
Subtracts the given vector from this vector and returns a reference to this vector.
constexpr void setZ(float z) noexcept
Sets the z coordinate of this point to the given finite z coordinate.
constexpr friend bool operator!=(QVector4D v1, QVector4D v2) noexcept
Returns true if v1 is not equal to v2; otherwise returns false.
QVector4D normalized() const noexcept
Returns the normalized unit vector form of this vector.
constexpr float lengthSquared() const noexcept
Returns the squared length of the vector from the origin.
constexpr QVector4D & operator*=(float factor) noexcept
Multiplies this vector's coordinates by the given finite factor, and returns a reference to this vect...
constexpr bool isNull() const noexcept
Returns true if the x, y, z, and w coordinates are set to 0.0, otherwise returns false.
QT_WARNING_POP constexpr friend QVector4D operator+(QVector4D v1, QVector4D v2) noexcept
//! friend
friend Q_GUI_EXPORT bool qFuzzyCompare(QVector4D v1, QVector4D v2) noexcept
//! friend
constexpr float x() const noexcept
Returns the x coordinate of this point.
float length() const noexcept
Returns the length of the vector from the origin.
constexpr void setY(float y) noexcept
Sets the y coordinate of this point to the given finite y coordinate.
constexpr float w() const noexcept
Returns the w coordinate of this point.
friend constexpr decltype(auto) get(V &&vec) noexcept
constexpr QVector2D toVector2D() const noexcept
Returns the 2D vector form of this 4D vector, dropping the z and w coordinates.
constexpr QVector2D toVector2DAffine() const noexcept
Returns the 2D vector form of this 4D vector, dividing the x and y coordinates by the w coordinate an...
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
constexpr friend QVector4D operator*(QVector4D v1, QVector4D v2) noexcept
//! friend
constexpr friend QVector4D operator/(QVector4D vector, float divisor)
//! friend
constexpr friend QVector4D operator-(QVector4D v1, QVector4D v2) noexcept
//! friend
constexpr QVector4D & operator+=(QVector4D vector) noexcept
Adds the given vector to this vector and returns a reference to this vector.
void normalize() noexcept
Normalizes the current vector in place.
constexpr QVector4D & operator/=(float divisor)
Divides this vector's coordinates by the given divisor, and returns a reference to this vector.
constexpr float y() const noexcept
Returns the y coordinate of this point.
QVector4D(Qt::Initialization) noexcept
constexpr QPointF toPointF() const noexcept
Returns the QPointF form of this 4D vector.
constexpr friend QVector4D operator*(float factor, QVector4D vector) noexcept
//! friend
static constexpr float dotProduct(QVector4D v1, QVector4D v2) noexcept
Returns the dot product of v1 and v2.
constexpr friend QVector4D operator-(QVector4D vector) noexcept
//! friendThis is an overloaded member function, provided for convenience. It differs from the above ...
constexpr float & operator[](int i)
constexpr friend QVector4D operator/(QVector4D vector, QVector4D divisor)
//! friend
constexpr QPoint toPoint() const noexcept
Returns the QPoint form of this 4D vector.
constexpr friend QVector4D operator*(QVector4D vector, float factor) noexcept
//! friend
constexpr QVector3D toVector3D() const noexcept
Returns the 3D vector form of this 4D vector, dropping the w coordinate.
constexpr QVector4D() noexcept
Constructs a null vector, i.e.
constexpr float z() const noexcept
Returns the z coordinate of this point.
constexpr void setW(float w) noexcept
Sets the w coordinate of this point to the given finite w coordinate.
constexpr QVector3D toVector3DAffine() const noexcept
Returns the 3D vector form of this 4D vector, dividing the x, y, and z coordinates by the w coordinat...
Combined button and popup list for selecting options.
#define QT_WARNING_DISABLE_FLOAT_COMPARE
bool qFuzzyIsNull(qfloat16 f) noexcept
auto qHypot(qfloat16 x, qfloat16 y)
bool qIsNull(qfloat16 f) noexcept
int qRound(qfloat16 d) noexcept
GLint GLfloat GLfloat GLfloat v2
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLenum GLsizei length
GLint GLfloat GLfloat GLfloat GLfloat v3
GLint GLenum GLboolean normalized
static float crossProduct(const QVector2D &sp, const QVector2D &p, const QVector2D &ep)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QVector2D &)
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, QVector2D vector)
QT_END_NAMESPACE typedef QT_PREPEND_NAMESPACE(quintptr) WId
view viewport() -> scroll(dx, dy, deviceRect)