Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. //Function for check if another point is in radius around point p
  2.  
  3. bool circle_check( double xpoint, double ypoint, double x_center, double y_center, double diameter, int holenumber) {
  4. if ( ( ( (xpoint-x_center)*(xpoint-x_center) ) + ( (ypoint-y_center)*(ypoint-y_center) ) ) <= (diameter*diameter/4) ) {
  5. printf ("Found needle inside hole no. %d with x,y: %.0lf,%.0lfn", holenbumber+1, xpoint, ypoint);
  6. fprintf(logfile, "Found needle inside hole no. %d with x,y: %.0lf,%.0lfn", holenbumber+1, xpoint, ypoint);
  7. return true;}
  8. else {
  9. return false;}
  10.  
  11. for (i=0;i<number_points;i++){
  12.  
  13. for (k=0;k<=number_circles;k++){
  14.  
  15. if (circle_check( new_coord[i].xcoord, new_coord[i].ycoord, holes[k].xhcoord, holes[k].yhcoord, holes[k].diamh, k) == false){
  16. fprintf( result, "%.0lft%.0lfn", new_coord[i].xcoord, new_coord[i].ycoord);
  17. }
  18. }
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement