36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <QPoint>
|
|
#include <QRect>
|
|
#include <QVector>
|
|
|
|
namespace Cevo {
|
|
|
|
// Equivalent of Geometric.pas. AddPoint/SubPoint/ComparePoint/RectEquals
|
|
// are NOT ported: QPoint/QRect already provide operator+/-/== directly.
|
|
struct Vector {
|
|
QPoint position;
|
|
QPoint direction;
|
|
|
|
double length() const;
|
|
double angle() const;
|
|
void setLength(double value);
|
|
|
|
static Vector create(QPoint p1, QPoint p2);
|
|
};
|
|
|
|
int distance(QPoint p1, QPoint p2);
|
|
double dot(QPoint p1, QPoint p2);
|
|
// Minimum distance between line segment vw and point p; intersect receives
|
|
// the closest point on the segment.
|
|
int pointToLineDistance(QPoint p, QPoint v, QPoint w, QPoint &intersect);
|
|
QPoint rotatePoint(QPoint center, QPoint p, double angle);
|
|
QVector<QPoint> rotatePoints(QPoint center, const QVector<QPoint> &points, double angle);
|
|
bool lineIntersect(QPoint lineAP1, QPoint lineAP2, QPoint lineBP1, QPoint lineBP2, QPoint &intersection);
|
|
double arcTan2Point(QPoint point);
|
|
double arcTanPoint(QPoint point);
|
|
QRect rectEnlarge(QRect rect, int value);
|
|
QRect shiftRect(QRect rect, QPoint delta);
|
|
|
|
} // namespace Cevo
|