PlanimetryCalculus.h 3.04 KB
Newer Older
1 2 3 4
#pragma once

#include <QLineF>
#include <QPointF>
5
#include <QPolygonF>
6 7 8
#include <QtMath>
#include <QLineF>

Valentin Platzgummer's avatar
Valentin Platzgummer committed
9 10
#include "PolygonCalculus.h"

11 12 13
class Circle;

namespace PlanimetryCalculus {
14

15 16 17
    enum IntersectType{InsideNoIntersection, InsideTouching, InsideIntersection,
                       OutsideIntersection, OutsideTouching, OutsideNoIntersection,
                       CirclesEqual, //Circle Circle intersection
18

Valentin Platzgummer's avatar
Valentin Platzgummer committed
19
                       Tangent, Secant, // Circle Line Intersetion
20

21 22 23
                       EdgeCornerIntersection, EdgeEdgeIntersection, CornerCornerIntersection,
                       LinesParallel, LinesEqual, // Line Line intersection

Valentin Platzgummer's avatar
Valentin Platzgummer committed
24
                       NoIntersection, Error // general
25 26
                       };

Valentin Platzgummer's avatar
Valentin Platzgummer committed
27 28 29 30
    typedef QList<QPair<int, int>> NeighbourList;
    typedef QList<QPointF> QPointFList;
    typedef QList<IntersectType> IntersectList;

Valentin Platzgummer's avatar
Valentin Platzgummer committed
31
    void rotateReference(QPointF &point, double alpha);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
32
    void rotateReference(QPointFList &points, double alpha);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
33 34 35
    void rotateReference(QLineF &line, double alpha);
    //void rotateReference(QPolygonF &polygon, double alpha);

36 37 38
    QPointF     rotateReturn(QPointF point, double alpha);
    QPointFList rotateReturn(QPointFList points, double alpha);
    QLineF      rotateReturn(QLineF line, double alpha);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
39 40
    //QPolygonF       rotateReturn(QPolygonF &polygon, double alpha);

Valentin Platzgummer's avatar
Valentin Platzgummer committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    bool intersects(const Circle &circle1, const Circle &circle2);
    bool intersects(const Circle &circle1, const Circle &circle2, IntersectType &type);
    bool intersects(const Circle &circle1, const Circle &circle2, QPointFList &intersectionPoints);
    bool intersects(const Circle &circle1, const Circle &circle2, QPointFList &intersectionPoints, IntersectType &type);
    bool intersects(const Circle &circle, const QLineF &line);
    bool intersects(const Circle &circle, const QLineF &line, IntersectType &type);
    bool intersects(const Circle &circle, const QLineF &line, QPointFList &intersectionPoints);
    bool intersects(const Circle &circle, const QLineF &line, QPointFList &intersectionPoints, IntersectType &type);


    bool intersects(const QLineF &line1, const QLineF &line2, QPointF &intersectionPt);
    bool intersects(const QLineF &line1, const QLineF &line2, QPointF &intersectionPt, IntersectType &type);
    bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList);
    bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList,  IntersectList &typeList);
    bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList,  NeighbourList &neighbourList);
    bool intersects(const QPolygonF &polygon, const QLineF &line, QPointFList &intersectionList,  NeighbourList &neighbourList, IntersectList &typeList);
57

58
    double distance(const QPointF &p1, const QPointF p2);
59 60
    double angle(const QPointF &p1, const QPointF p2);
    double angleDegree(const QPointF &p1, const QPointF p2);
61 62
    double truncateAngle(double angle);
    double truncateAngleDegree(double angle);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
63 64

    template <typename T> int signum(T val);
65 66
}

67

68