Guest User

Untitled

a guest
Jul 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) < d*d
  2.  
  3. (Math.Pow(x1-x2,2)+Math.Pow(y1-y2,2)) < (d*d);
  4.  
  5. // assuming p1 and p2 data types
  6. Point p1, p2;
  7. // distanc can be calculated as follows
  8. double distance = Point.Subtract(p2, p1).Length;
  9.  
  10. // assuming p1 and p2 data types
  11. Point p1, p2;
  12. // distanc can be calculated as follows
  13. double distanceSquared = (p2 - p1).LengthSquared;
  14.  
  15. private static double GetDistance(double x1, double y1, double x2, double y2)
  16. {
  17. return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
  18. }
  19.  
  20. double distance = GetDistance(x1, y1, x2, y2)
  21. if(distance <= 5)
  22. {
  23. //Do stuff
  24. }
  25.  
  26. double dX = x1 - x2;
  27. double dY = y1 - y2;
  28. double multi = dX * dX + dY * dY;
  29. double rad = Math.Round(Math.Sqrt(multi), 3);
  30.  
  31. dX = X1 - X2;
  32. dY = Y1 - Y2;
  33.  
  34. if (dX*dX + dY*dY > (5*5))
  35. {
  36. //your code
  37. }
Add Comment
Please, Sign In to add comment