Написал 10ю задачу по Геометрии
This commit is contained in:
parent
19e0da8dc6
commit
241b43fa19
20 changed files with 432 additions and 0 deletions
40
ComputationalGeometry/10Ex/main.c
Normal file
40
ComputationalGeometry/10Ex/main.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "tools.h"
|
||||
#include "polygon.h"
|
||||
|
||||
int main(void) {
|
||||
points ps;
|
||||
double shift;
|
||||
polygon plgn, new_polygon;
|
||||
FILE * file = getFile();
|
||||
if (file == NULL) return -1;
|
||||
|
||||
ps = getPoints(file);
|
||||
if (ps.arr == NULL) return -2;
|
||||
if (ps.len < 3) {
|
||||
printf("Incorrect polygon!\n");
|
||||
return -4;
|
||||
}
|
||||
|
||||
shift = getShift();
|
||||
|
||||
if (-eps < shift && shift < eps) return -3;
|
||||
|
||||
plgn.pts = ps;
|
||||
repairPolygon(&plgn);
|
||||
|
||||
if (plgn.pts.len <= 1) {
|
||||
printf("Incorrect polygon!\n");
|
||||
return -4;
|
||||
}
|
||||
|
||||
printPolygon(plgn, "\nOriginal polygon:\n");
|
||||
|
||||
new_polygon = getPolygon(&plgn, shift);
|
||||
|
||||
printPolygon(new_polygon, "\n\nNew polygon:\n");
|
||||
|
||||
free(ps.arr);
|
||||
free(new_polygon.pts.arr);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue