QGIS API Documentation  3.0.2-Girona (307d082)
qgsvector3d.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvector3d.h
3  --------------------------------------
4  Date : November 2017
5  Copyright : (C) 2017 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSVECTOR3D_H
17 #define QGSVECTOR3D_H
18 
19 #include "qgis_3d.h"
20 
28 class _3D_EXPORT QgsVector3D
29 {
30  public:
32  QgsVector3D() = default;
33 
35  QgsVector3D( double x, double y, double z )
36  : mX( x ), mY( y ), mZ( z ) {}
37 
39  bool isNull() const { return mX == 0 && mY == 0 && mZ == 0; }
40 
42  double x() const { return mX; }
44  double y() const { return mY; }
46  double z() const { return mZ; }
47 
49  void set( double x, double y, double z )
50  {
51  mX = x;
52  mY = y;
53  mZ = z;
54  }
55 
56  bool operator==( const QgsVector3D &other ) const
57  {
58  return mX == other.mX && mY == other.mY && mZ == other.mZ;
59  }
60  bool operator!=( const QgsVector3D &other ) const
61  {
62  return !operator==( other );
63  }
64 
67  {
68  return QgsVector3D( mX + other.mX, mY + other.mY, mZ + other.mZ );
69  }
70 
73  {
74  return QgsVector3D( mX - other.mX, mY - other.mY, mZ - other.mZ );
75  }
76 
77  private:
78  double mX = 0, mY = 0, mZ = 0;
79 };
80 
81 #endif // QGSVECTOR3D_H
3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
Definition: qgsvector3d.h:28
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
double y() const
Returns Y coordinate.
Definition: qgsvector3d.h:44
QgsVector3D operator-(const QgsVector3D &other)
Returns difference of two vectors.
Definition: qgsvector3d.h:72
double z() const
Returns Z coordinate.
Definition: qgsvector3d.h:46
bool isNull() const
Returns true if all three coordinates are zero.
Definition: qgsvector3d.h:39
bool operator==(const QgsVector3D &other) const
Definition: qgsvector3d.h:56
bool operator!=(const QgsVector3D &other) const
Definition: qgsvector3d.h:60
QgsVector3D(double x, double y, double z)
Constructs a vector from given coordinates.
Definition: qgsvector3d.h:35
QgsVector3D operator+(const QgsVector3D &other)
Returns sum of two vectors.
Definition: qgsvector3d.h:66
double x() const
Returns X coordinate.
Definition: qgsvector3d.h:42