38 : mX( x ), mY( y ), mZ( z ) {}
42 : mX( v.x() ), mY( v.y() ), mZ( v.z() ) {}
83 return mX == other.mX && mY == other.mY && mZ == other.mZ;
93 return QgsVector3D( mX + other.mX, mY + other.mY, mZ + other.mZ );
99 return QgsVector3D( mX - other.mX, mY - other.mY, mZ - other.mZ );
116 return QgsVector3D( mX * factor, mY * factor, mZ * factor );
122 return QgsVector3D( mX / factor, mY / factor, mZ / factor );
128 return v1.x() * v2.x() + v1.y() * v2.y() + v1.z() * v2.z();
134 return QgsVector3D( v1.y() * v2.z() - v1.z() * v2.y(),
135 v1.z() * v2.x() - v1.x() * v2.z(),
136 v1.x() * v2.y() - v1.y() * v2.x() );
142 return sqrt( mX * mX + mY * mY + mZ * mZ );
148 const double len = length();
160 return std::sqrt( ( mX - other.x() ) * ( mX - other.x() ) +
161 ( mY - other.y() ) * ( mY - other.y() ) +
162 ( mZ - other.z() ) * ( mZ - other.z() ) );
170 const double t = dotProduct( v, d );
181 QString str =
"Vector3D (";
196 QVector3D
toVector3D() const
SIP_HOLDGIL {
return QVector3D(
static_cast< float >( mX ),
static_cast< float >( mY ),
static_cast< float >( mZ ) ); }
199 SIP_PYOBJECT __repr__();
201 QString str = QStringLiteral(
"<QgsVector3D: %1>" ).arg( sipCpp->toString() );
202 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
206 double mX = 0, mY = 0, mZ = 0;
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
double y() const
Returns Y coordinate.
bool operator!=(const QgsVector3D &other) const
bool operator==(const QgsVector3D &other) const
double z() const
Returns Z coordinate.
void setZ(double z)
Sets Z coordinate.
QString toString(int precision=17) const
Returns a string representation of the 3D vector.
bool isNull() const
Returns true if all three coordinates are zero.
double distance(const QgsVector3D &other) const
Returns the distance with the other QgsVector3D.
QVector3D toVector3D() const
Converts the current object to QVector3D.
QgsVector3D(double x, double y, double z)
Constructs a vector from given coordinates.
QgsVector3D(const QVector3D &v)
Constructs a vector from single-precision QVector3D.
QgsVector3D operator+(const QgsVector3D &other) const
Returns sum of two vectors.
static double dotProduct(const QgsVector3D &v1, const QgsVector3D &v2)
Returns the dot product of two vectors.
double x() const
Returns X coordinate.
QgsVector3D operator-(const QgsVector3D &other) const
Returns difference of two vectors.
static QgsVector3D perpendicularPoint(const QgsVector3D &v1, const QgsVector3D &v2, const QgsVector3D &vp)
Returns the perpendicular point of vector vp from [v1 - v2].
void setX(double x)
Sets X coordinate.
void normalize()
Normalizes the current vector in place.
const QgsVector3D operator-() const
Swaps the sign of the components of the vector.
static QgsVector3D crossProduct(const QgsVector3D &v1, const QgsVector3D &v2)
Returns the cross product of two vectors.
void set(double x, double y, double z)
Sets vector coordinates.
void setY(double y)
Sets Y coordinate.
double length() const
Returns the length of the vector.
QgsVector3D()=default
Constructs a null vector.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
QgsMargins operator/(const QgsMargins &margins, double divisor)
Returns a QgsMargins object that is formed by dividing the components of the given margins by the giv...