Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) < d*d
- (Math.Pow(x1-x2,2)+Math.Pow(y1-y2,2)) < (d*d);
- // assuming p1 and p2 data types
- Point p1, p2;
- // distanc can be calculated as follows
- double distance = Point.Subtract(p2, p1).Length;
- // assuming p1 and p2 data types
- Point p1, p2;
- // distanc can be calculated as follows
- double distanceSquared = (p2 - p1).LengthSquared;
- private static double GetDistance(double x1, double y1, double x2, double y2)
- {
- return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
- }
- double distance = GetDistance(x1, y1, x2, y2)
- if(distance <= 5)
- {
- //Do stuff
- }
- double dX = x1 - x2;
- double dY = y1 - y2;
- double multi = dX * dX + dY * dY;
- double rad = Math.Round(Math.Sqrt(multi), 3);
- dX = X1 - X2;
- dY = Y1 - Y2;
- if (dX*dX + dY*dY > (5*5))
- {
- //your code
- }
Add Comment
Please, Sign In to add comment