Advertisement
Guest User

Untitled

a guest
May 6th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. var points = new List<Point>();
  2. Point source = ...
  3. ....
  4. var closestPoints = points.Where(point => point != source).
  5. OrderBy(point => NotReallyDistanceButShouldDo(source, point)).
  6. Take(20);
  7.  
  8. private double NotReallyDistanceButShouldDo(Point source, Point target)
  9. {
  10. return Math.Pow(target.X - source.X, 2) + Math.Pow(target.Y - source.Y, 2);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement