19 #include "qgis_core.h"
39 : mX( x ), mY( y ), mZ( z ) {}
43 : mX( v.x() ), mY( v.y() ), mZ( v.z() ) {}
46 bool isNull()
const {
return mX == 0 && mY == 0 && mZ == 0; }
49 double x()
const {
return mX; }
51 double y()
const {
return mY; }
53 double z()
const {
return mZ; }
56 void set(
double x,
double y,
double z )
65 return mX == other.mX && mY == other.mY && mZ == other.mZ;
75 return QgsVector3D( mX + other.mX, mY + other.mY, mZ + other.mZ );
81 return QgsVector3D( mX - other.mX, mY - other.mY, mZ - other.mZ );
88 return QgsVector3D( mX * factor, mY * factor, mZ * factor );
94 return QgsVector3D( mX / factor, mY / factor, mZ / factor );
100 return v1.
x() * v2.
x() + v1.
y() * v2.
y() + v1.
z() * v2.
z();
107 v1.
z() * v2.
x() - v1.
x() * v2.
z(),
108 v1.
x() * v2.
y() - v1.
y() * v2.
x() );
112 double length()
const
114 return sqrt( mX * mX + mY * mY + mZ * mZ );
120 double len = length();
132 return std::sqrt( ( mX - other.
x() ) * ( mX - other.
x() ) +
133 ( mY - other.
y() ) * ( mY - other.
y() ) +
134 ( mZ - other.
z() ) * ( mZ - other.
z() ) );
142 double t = dotProduct( v, d );
153 QString str =
"Vector3D (";
164 SIP_PYOBJECT __repr__();
166 QString str = QStringLiteral(
"<QgsVector3D: %1>" ).arg( sipCpp->toString() );
167 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
171 double mX = 0, mY = 0, mZ = 0;
174 #endif // QGSVECTOR3D_H