![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Represents two doubles as a mathematical 2D vector. More...
#include <qcustomplot.h>
Public Member Functions | |
| QCPVector2D () | |
| QCPVector2D (double x, double y) | |
| QCPVector2D (const QPoint &point) | |
| QCPVector2D (const QPointF &point) | |
| double | x () const |
| double | y () const |
| double & | rx () |
| double & | ry () |
| void | setX (double x) |
| void | setY (double y) |
| double | length () const |
| double | lengthSquared () const |
| QPoint | toPoint () const |
| QPointF | toPointF () const |
| bool | isNull () const |
| void | normalize () |
| QCPVector2D | normalized () const |
| QCPVector2D | perpendicular () const |
| double | dot (const QCPVector2D &vec) const |
| double | distanceSquaredToLine (const QCPVector2D &start, const QCPVector2D &end) const |
| double | distanceSquaredToLine (const QLineF &line) const |
| double | distanceToStraightLine (const QCPVector2D &base, const QCPVector2D &direction) const |
| QCPVector2D & | operator*= (double factor) |
| QCPVector2D & | operator/= (double divisor) |
| QCPVector2D & | operator+= (const QCPVector2D &vector) |
| QCPVector2D & | operator-= (const QCPVector2D &vector) |
Related Functions | |
(Note that these are not member functions.) | |
| QDebug | operator<< (QDebug d, const QCPVector2D &vec) |
Represents two doubles as a mathematical 2D vector.
This class acts as a replacement for QVector2D with the advantage of double precision instead of single, and some convenience methods tailored for the QCustomPlot library.
Definition at line 543 of file qcustomplot.h.
| QCPVector2D::QCPVector2D | ( | ) |
Creates a QCPVector2D object and initializes the x and y coordinates to 0.
Definition at line 96 of file qcustomplot.cpp.
Referenced by distanceSquaredToLine().
| QCPVector2D::QCPVector2D | ( | double | x, |
| double | y | ||
| ) |
Creates a QCPVector2D object and initializes the x and y coordinates with the specified values.
Definition at line 102 of file qcustomplot.cpp.
| QCPVector2D::QCPVector2D | ( | const QPoint & | point | ) |
Creates a QCPVector2D object and initializes the x and y coordinates respective coordinates of the specified point.
Definition at line 108 of file qcustomplot.cpp.
| QCPVector2D::QCPVector2D | ( | const QPointF & | point | ) |
Creates a QCPVector2D object and initializes the x and y coordinates respective coordinates of the specified point.
Definition at line 114 of file qcustomplot.cpp.
| double QCPVector2D::distanceSquaredToLine | ( | const QCPVector2D & | start, |
| const QCPVector2D & | end | ||
| ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the squared shortest distance of this vector (interpreted as a point) to the finite line segment given by start and end.
Definition at line 147 of file qcustomplot.cpp.
References dot(), and lengthSquared().
Referenced by QCPFinancial::candlestickSelectTest(), distanceSquaredToLine(), QCPFinancial::ohlcSelectTest(), QCPCurve::pointDistance(), QCPErrorBars::pointDistance(), QCPGraph::pointDistance(), QCPAbstractItem::rectDistance(), QCPStatisticalBox::selectTest(), QCPItemCurve::selectTest(), and QCPItemBracket::selectTest().
| double QCPVector2D::distanceSquaredToLine | ( | const QLineF & | line | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the squared shortest distance of this vector (interpreted as a point) to the finite line segment given by line.
Definition at line 170 of file qcustomplot.cpp.
References distanceSquaredToLine(), and QCPVector2D().
| double QCPVector2D::distanceToStraightLine | ( | const QCPVector2D & | base, |
| const QCPVector2D & | direction | ||
| ) | const |
Returns the shortest distance of this vector (interpreted as a point) to the infinite straight line given by a base point and a direction vector.
Definition at line 181 of file qcustomplot.cpp.
References dot(), length(), and perpendicular().
Referenced by QCPItemStraightLine::selectTest().
|
inline |
Returns the dot/scalar product of this vector with the specified vector vec.
Definition at line 570 of file qcustomplot.h.
Referenced by distanceSquaredToLine(), and distanceToStraightLine().
|
inline |
Returns whether this vector is null. A vector is null if qIsNull returns true for both x and y coordinates, i.e. if both are binary equal to 0.
Definition at line 566 of file qcustomplot.h.
Referenced by QCPLineEnding::draw().
|
inline |
Returns the length of this vector.
Definition at line 561 of file qcustomplot.h.
Referenced by distanceToStraightLine(), normalize(), QCPCurve::pointDistance(), and QCPItemTracer::selectTest().
|
inline |
Returns the squared length of this vector. In some situations, e.g. when just trying to find the shortest vector of a group, this is faster than calculating length, because it avoids calculation of a square root.
Definition at line 562 of file qcustomplot.h.
Referenced by distanceSquaredToLine(), QCPCurve::pointDistance(), QCPGraph::pointDistance(), and QCPAbstractPlottable1D< DataType >::selectTest().
| void QCPVector2D::normalize | ( | ) |
Normalizes this vector. After this operation, the length of the vector is equal to 1.
Definition at line 122 of file qcustomplot.cpp.
References length().
| QCPVector2D QCPVector2D::normalized | ( | ) | const |
Returns a normalized version of this vector. The length of the returned vector is equal to 1.
Definition at line 134 of file qcustomplot.cpp.
References result.
Referenced by QCPItemBracket::anchorPixelPosition(), QCPItemBracket::draw(), QCPLineEnding::draw(), and QCPItemBracket::selectTest().
| QCPVector2D & QCPVector2D::operator*= | ( | double | factor | ) |
Scales this vector by the given factor, i.e. the x and y components are multiplied by factor.
Definition at line 191 of file qcustomplot.cpp.
| QCPVector2D & QCPVector2D::operator+= | ( | const QCPVector2D & | vector | ) |
Adds the given vector to this vector component-wise.
Definition at line 210 of file qcustomplot.cpp.
| QCPVector2D & QCPVector2D::operator-= | ( | const QCPVector2D & | vector | ) |
subtracts the given vector from this vector component-wise.
Definition at line 219 of file qcustomplot.cpp.
| QCPVector2D & QCPVector2D::operator/= | ( | double | divisor | ) |
Scales this vector by the given divisor, i.e. the x and y components are divided by divisor.
Definition at line 201 of file qcustomplot.cpp.
|
inline |
Returns a vector perpendicular to this vector, with the same length.
Definition at line 569 of file qcustomplot.h.
Referenced by QCPItemBracket::anchorPixelPosition(), distanceToStraightLine(), QCPItemBracket::draw(), QCPLineEnding::draw(), and QCPItemBracket::selectTest().
|
inline |
Definition at line 553 of file qcustomplot.h.
|
inline |
Definition at line 554 of file qcustomplot.h.
|
inline |
Sets the x coordinate of this vector to x.
Definition at line 557 of file qcustomplot.h.
References x.
|
inline |
Sets the y coordinate of this vector to y.
Definition at line 558 of file qcustomplot.h.
References y.
|
inline |
Returns a QPoint which has the x and y coordinates of this vector, truncating any floating point information.
Definition at line 563 of file qcustomplot.h.
Referenced by QCPItemBracket::anchorPixelPosition(), QCPItemBracket::draw(), and QCPItemBracket::selectTest().
|
inline |
Returns a QPointF which has the x and y coordinates of this vector.
Definition at line 564 of file qcustomplot.h.
Referenced by QCPItemBracket::anchorPixelPosition(), QCPItemCurve::draw(), QCPItemBracket::draw(), QCPLineEnding::draw(), QCPItemLine::getRectClippedLine(), and QCPItemStraightLine::getRectClippedStraightLine().
|
inline |
Definition at line 551 of file qcustomplot.h.
Referenced by QCPItemLine::getRectClippedLine(), QCPItemStraightLine::getRectClippedStraightLine(), and operator<<().
|
inline |
Definition at line 552 of file qcustomplot.h.
Referenced by QCPItemLine::getRectClippedLine(), QCPItemStraightLine::getRectClippedStraightLine(), and operator<<().
|
related |
Prints vec in a human readable format to the qDebug output.
Definition at line 627 of file qcustomplot.h.