Exemplo n.º 1
0
int main ()
{
  // Construct the first polygon (a triangle).
  Polygon_2   P;

  P.push_back (Point_2 (0, 0));
  P.push_back (Point_2 (6, 0));
  P.push_back (Point_2 (3, 5));

  // Construct the second polygon (a triangle).
  Polygon_2   Q;

  Q.push_back (Point_2 (0, 0));
  Q.push_back (Point_2 (2, -2));
  Q.push_back (Point_2 (2, 2));

  // Compute the Minkowski sum.
  Polygon_with_holes_2  sum = minkowski_sum_2 (P, Q);

  CGAL_assertion (sum.number_of_holes() == 0);

  std::cout << "P = "; print_polygon (P);
  std::cout << "Q = "; print_polygon (Q);
  std::cout << "P (+) Q = "; print_polygon (sum.outer_boundary());

  return (0);
}
Exemplo n.º 2
0
int main(int argc, char * argv[]){
	if(argc < 2){
		printf("Usage: %s <filename> <Q.x> <Q.y>\n", argv[0]);
		return EXIT_FAILURE;
	}
	int n;
	point * polygon = parsePolygon(argv[1], &n);
	point O = {1,1};
	polar_angle_sort(polygon, n, O);
	print_polygon(polygon, n); 
	return EXIT_SUCCESS;
}
Exemplo n.º 3
0
void print_polygons(FILE* fptr, struct PolygonVec *self)
{
    if (self) {
        size_t i;
        struct Polygon* ply=NULL;

        ply = &self->data[0];
        for (i=0; i<self->size; i++) {
            print_polygon(fptr,ply);
            ply++;
        }
    }
}
Exemplo n.º 4
0
int main(void) {
    point in[MAXPOLY];		/* input points */
    polygon hull;			/* convex hull */
    int n;				/* number of points */
    int i;				/* counter */

    printf("enter # points: ");
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        printf("enter point #%d (x, y): ", i);
        scanf("%lf %lf", &in[i][X], &in[i][Y]);
    }

    convex_hull(in, n, &hull);
    print_polygon(&hull);

    return 0;
}