-
Notifications
You must be signed in to change notification settings - Fork 0
/
myalgorithm.h
76 lines (47 loc) · 2.12 KB
/
myalgorithm.h
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
70
71
72
73
74
75
76
#ifndef MYALGORITHM_H
#define MYALGORITHM_H
#include<QPoint>
#include<qvector.h>
#define DDA 1
#define Bresenham 2
#define Cohen 1
#define Liang 2
#define INSIDE 0
#define LEFT 1
#define RIGHT 2
#define BOTTOM 4
#define TOP 8
#define Bezier 1
#define BSpline 2
//drawing part
QVector<QPoint> drawLineDda(QPoint startPoint,QPoint endPoint,bool drawStart=true);
QVector<QPoint> drawLineBresenham(QPoint startPoint,QPoint endPoint,bool drawStart=true);
QVector<QPoint> drawPolygonDda(QVector<QPoint>&points);
QVector<QPoint> drawPolygonBresenham(QVector<QPoint>&points);
QVector<QPoint> drawEllipseAlgorithm(QPoint center,int rx,int ry);
//TODO
//QVector<QPoint> drawCurveBezier(QVector<QPoint>points);
//TODO
//QVector<QPoint> drawCurveBSpline(QVector<QPoint>points);
//TODO
//moving part:translate,cut,rotate
void myScale(QVector<QPoint>&points,QPoint center,double s);
void myScaleSinglePoint(QPoint& point,QPoint center,double s);
void translate(QVector<QPoint>&points,int dx,int dy);
void myRotate(QVector<QPoint>&points,QPoint ¢er,int r);//clockwise
void myRotatePoint(QPoint&point,QPoint ¢er,int r);//rotate single
void myRotateArc(QVector<QPoint>&points,QPoint ¢er,double r);//clockwise
void myRotatePointArc(QPoint&point,QPoint ¢er,double r);//rotate single
int calculateRotateAngel(QPoint¢er,QPoint&startPoint,QPoint&endPoint);//not in arc
double calculateRotateArc(QPoint¢er,QPoint&startPoint,QPoint&endPoint);//inarc
int mydistance2(QPoint&p1,QPoint&p2);
//裁剪算法:参数为矩形的两个顶点,先计算出xmin,xmax,ymin,ymax。参数还有start,end两个点(引用)
bool myClipCoHen(QPoint&rectPoint1,QPoint&rectPoint2,QPoint&start,QPoint&end);
int computeCode(int xmin,int xmax,int ymin,int ymax,int x,int y);
bool myClipLiang(QPoint&rectPoint1,QPoint&rectPoint2,QPoint&start,QPoint&end);
long long myConbination(int n,int m);//计算组合数
int mySumDistance(QVector<QPoint>& points);
QVector<QPoint> myBezierCurve(QVector<QPoint> ctlPoints);
QVector<QPoint> myBSplineCurve(QVector<QPoint> ctlPoints,int k);
double getB(int i,int k,QVector<double>&uis,double u);
#endif // MYALGORITHM_H