Advertisement
mrhumbility

Dont Find Same nearpoint twice

Oct 9th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. int numpoints = i@numpt;
  2. int secondinput[];
  3. for(int y = 0; y < npoints(1); y++){
  4.     secondinput[y] = y;
  5. }
  6.  
  7. int near(int points[]; vector pos){
  8.     int numberofpoints = len(points);
  9.     float d1 = 99999999;
  10.     int winner = -1;
  11.     for(int x = 0; x < numberofpoints; x++){
  12.         vector poss = point(1, "P", points[x]);
  13.         float d2 = distance(pos, poss);
  14.         if(d2 < d1){
  15.             d1 = d2;
  16.             winner = points[x];
  17.         }
  18.     }
  19.     return winner;
  20. }
  21.  
  22.  
  23.  
  24. for(int i = 0; i < numpoints; i++){
  25.     vector p = point(0, "P", i);
  26.     int nearpt = near(secondinput, p);
  27.     removevalue(secondinput, nearpt);
  28.     vector p2 = point(1, "P", nearpt);
  29.     int newpt = addpoint(0, p2);
  30.     addprim(0, "polyline", i, newpt);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement