19 #include "qgis_core.h" 37 : mX( x ), mY( y ), mZ( z ) {}
40 bool isNull()
const {
return mX == 0 && mY == 0 && mZ == 0; }
43 double x()
const {
return mX; }
45 double y()
const {
return mY; }
47 double z()
const {
return mZ; }
50 void set(
double x,
double y,
double z )
59 return mX == other.mX && mY == other.mY && mZ == other.mZ;
69 return QgsVector3D( mX + other.mX, mY + other.mY, mZ + other.mZ );
75 return QgsVector3D( mX - other.mX, mY - other.mY, mZ - other.mZ );
82 return QgsVector3D( mX * factor, mY * factor, mZ * factor );
88 return QgsVector3D( mX / factor, mY / factor, mZ / factor );
94 return v1.
x() * v2.
x() + v1.
y() * v2.
y() + v1.
z() * v2.
z();
101 v1.
z() * v2.
x() - v1.
x() * v2.
z(),
102 v1.
x() * v2.
y() - v1.
y() * v2.
x() );
108 return sqrt( mX * mX + mY * mY + mZ * mZ );
114 double len = length();
125 double mX = 0, mY = 0, mZ = 0;
128 #endif // QGSVECTOR3D_H 3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
double length() const
Returns the length of the vector.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
double y() const
Returns Y coordinate.
static double dotProduct(const QgsVector3D &v1, const QgsVector3D &v2)
Returns the dot product of two vectors.
static QgsVector3D crossProduct(const QgsVector3D &v1, const QgsVector3D &v2)
Returns the cross product of two vectors.
void normalize()
Normalizes the current vector in place.
double z() const
Returns Z coordinate.
QgsVector3D operator-(const QgsVector3D &other) const
Returns difference of two vectors.
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...
QgsVector3D operator+(const QgsVector3D &other) const
Returns sum of two vectors.
bool isNull() const
Returns true if all three coordinates are zero.
bool operator==(const QgsVector3D &other) const
bool operator!=(const QgsVector3D &other) const
QgsVector3D(double x, double y, double z)
Constructs a vector from given coordinates.
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
double x() const
Returns X coordinate.