Esempio n. 1
0
/* returns true if polyhedron intersects unit-radius sphere centered
   at origin */
bool
intersect_polyhedron(const ppogl::Polyhedron& p)
{
	for(int i=0; i<p.numPolygons; i++){
		if(intersect_polygon(p.polygons[i], p.vertices)){
			return true;
		}
    } 
    return false;
} 
Esempio n. 2
0
/* returns True iff polyhedron intersects unit-radius sphere centered
 at origin */
bool_t intersect_polyhedron( polyhedron_t p )
{
    bool_t hit = False;
    int i;
    
    for (i=0; i<p.num_polygons; i++) {
        hit = intersect_polygon( p.polygons[i], p.vertices );
        if ( hit == True ) 
            break;
    } 
    return hit;
} 
int main(void){
  Point *poly1, *poly2, *intersection;
  int n1, n2, n3, i;
  
  while ((n1 = read_poly(&poly1))) {
    n2 = read_poly(&poly2);
    n3 = intersect_polygon(poly1, n1, poly2, n2, &intersection);
    free(poly1);
    free(poly2);
    if (n3 >= 3) {
      for (i = 0; i < n3; i++) {
        printf("(%0.2f, %0.2f) ", intersection[i].x, intersection[i].y);
      }
      printf("\n");
      free(intersection);
    } else {
      printf("Empty Intersection\n");
    }
  }
  return 0;
}