yy1717
2020-08-07 e43f00fbe051dc8f9dfa5a19143c38613b64ecad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Created by YY on 2019/4/30.
//
 
#ifndef GUI_GEOMETRY_H
#define GUI_GEOMETRY_H
 
#include <stdint.h>
#include <initializer_list>
 
enum Relation
{
    GM_None,
    GM_Tangent,
    GM_Intersection,
    GM_Containment
};
 
typedef struct PointF_ {
    double X;
    double Y;
} PointF;
 
typedef struct Line_ {
    double X1;
    double Y1;
    double X2;
    double Y2;
} Line;
 
typedef struct Polygon_ {
    int num;
    PointF *point;
} Polygon;
 
inline double toRadians(double degree);
inline double toDegree(double radians);
inline bool isEqual(double a, double b);
inline bool isEqual2(double a, double b);
double round(double number, unsigned int bits);
 
void MakeLine(Line *line, const PointF *p1, const PointF *p2);
void MakePolygon(Polygon *polygon, std::initializer_list<PointF> point_set);
void CleanPolygon(Polygon *polygon);
void MakeHidePoint(PointF *point, const PointF *bp, const Line *bl);
 
Relation IntersectionOf(const Polygon *polygon1, const Polygon *polygon2);
Relation IntersectionOf(Line line, const Polygon *polygon);
Relation IntersectionOf(PointF point, const Polygon *polygon);
Relation IntersectionOf(PointF point, Line line);
Relation IntersectionOf(Line line1, Line line2);
double DistanceOf(PointF point1, PointF point2);
double DistanceOf(PointF point, Line line);
double YawOf(PointF p1, PointF p2);
double CalculateAngle(Line base, Line dest);
PointF rotatePoint(PointF oldPoint, PointF centre, double degree);
bool InsidePolygon(const Polygon *t1, const Polygon *t2);
bool PartInsidePolygon(const Polygon *t1, const Polygon *t2);
bool OutsidePolygon(const Polygon *t1, const Polygon *t2);
int IntersectionOfLine(PointF p1, PointF p2, PointF p3);
int IntersectionOfLine(PointF p, Line line);
PointF GetVerticalPoint(PointF p1, PointF p2, PointF p3);
bool VerticalPointOnLine(PointF point, Line line);
bool VerticalPointOnLine(PointF point, Line line, PointF &vp);
PointF Calc3Point(PointF p1, PointF p2, double L, char dir);
PointF PointExtend(PointF ori, double length, double yaw);
bool IsSamePoint(PointF p1, PointF p2);
 
#endif //GUI_GEOMETRY_H