QGIS API Documentation  3.0.2-Girona (307d082)
qgsvector.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvector.h - QgsVector
3 
4  ---------------------
5  begin : 24.2.2017
6  copyright : (C) 2017 by Matthias Kuhn
7  email : [email protected]
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSVECTOR_H
17 #define QGSVECTOR_H
18 
19 #include "qgis_core.h"
20 
27 class CORE_EXPORT QgsVector
28 {
29 
30  public:
31 
35  QgsVector() = default;
36 
42  QgsVector( double x, double y );
43 
45  QgsVector operator-() const;
46 
51  QgsVector operator*( double scalar ) const;
52 
57  QgsVector operator/( double scalar ) const;
58 
64  double operator*( QgsVector v ) const;
65 
70  QgsVector operator+( QgsVector other ) const;
71 
76  QgsVector &operator+=( const QgsVector other );
77 
82  QgsVector operator-( const QgsVector other ) const;
83 
88  QgsVector &operator-=( const QgsVector other );
89 
93  double length() const;
94 
99  double x() const;
100 
105  double y() const;
106 
110  QgsVector perpVector() const;
111 
115  double angle() const;
116 
120  double angle( QgsVector v ) const;
121 
126  QgsVector rotateBy( double rot ) const;
127 
132  QgsVector normalized() const;
133 
135  bool operator==( QgsVector other ) const;
136 
138  bool operator!=( QgsVector other ) const;
139 
140  private:
141  double mX = 0.0, mY = 0.0;
142 
143 };
144 
145 #endif // QGSVECTOR_H
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
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...
Definition: qgsmargins.h:262
QDateTime operator+(const QDateTime &start, QgsInterval interval)
A class to represent a vector.
Definition: qgsvector.h:27
QgsInterval operator-(const QDateTime &dt1, const QDateTime &dt2)
Returns the interval between two datetimes.
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
Definition: qgsmargins.h:242