本文整理汇总了C++中Poly::plotPoly方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::plotPoly方法的具体用法?C++ Poly::plotPoly怎么用?C++ Poly::plotPoly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::plotPoly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/*
Enter n for polygon
5
Enter points of polygon in clockwise/anticlockwise order\n
-20 50
50 200
120 50
50 -200
-20 50
Enter rectangle
0 -100 100 150
*/
int main()
{
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "");
setbkcolor(WHITE);
cleardevice();
drawAxis(BLACK);
int n;
Poly *head = NULL;
printf("Enter n for polygon");
scanf("%d", &n);
printf("Enter points of polygon in clockwise/anticlockwise order\n");
for(int i = 0; i<n; i++)
{
Point p;
scanf("%lf%lf",&p.x,&p.y);
Poly *x = (Poly *) malloc (sizeof(Poly));
*x = {p, head};
head = x;
}
head->plotPoly(MAGENTA,0);
Rect r;
printf("Enter rectangle\n");
scanf("%lf%lf%lf%lf",&r.min.x, &r.min.y, &r.max.x, &r.max.y);
r.plotRect(BLUE);
Poly *op = sutherlandHodgeman(head, &r);
op->plotPoly(YELLOW,0);
getch();
return 0;
}
示例2: main
/*
-30 70
60 100
80 -10
20 -20
-80 0
-30 70
Enter line
-150 100
150 20
-30 70
60 100
80 -10
20 -20
-80 0
-30 70
Enter line
*/
int main()
{
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "");
setbkcolor(WHITE);
cleardevice();
drawAxis(BLACK);
int n;
Poly *poly = NULL;
printf("Enter n for convex polygon\n");
scanf("%d", &n);
printf("Enter points in clockwise/anticlockwise order\n");
for(int i = 0; i<n; i++)
{
int x,y;
scanf("%d%d",&x,&y);
Point p = Point{x,y};
Poly *newPoly = (Poly *)malloc(sizeof(Poly));
*newPoly = Poly{p, poly};
poly = newPoly;
}
poly->plotPoly(BLACK, 0);
printf("Enter line\n");
Line l;
scanf("%lf%lf%lf%lf", &l.p1.x, &l.p1.y, &l.p2.x, &l.p2.y);
l.plotLineDDA(BLUE);
cyrusBeck(poly, &l, YELLOW);
getch();
closegraph();
return 0;
}
示例3: main
int main()
{
initwindow(700, 700);
drawAxis(WHITE);
Point p[] = {Point{-20,50}, Point{50,200}, Point{120,50}, Point{50, -200}, Point{-20, 50} };
int n = sizeof(p)/ sizeof(Point);
Poly *head = NULL;
// i was doing this - http://stackoverflow.com/questions/5136393/for-loop-local-variables-in-c
for(int i = 0; i<n; i++)
{
Poly *x = (Poly *) malloc (sizeof(Poly));
*x = {p[i], head};
head = x;
}
head->plotPoly(YELLOW,0);
Rect r = {Point{0,0}, Point{100, 150} };
r.plotRect(BLUE);
Poly *op = sutherlandHodgeman(head, &r);
op->plotPoly(RED,1);
delay(2000);
return 0;
}