With monday.comâ€™s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.
>> don't remember the distance formula though
square root from ( x^2 + y^2 )
You'll always have points that will be "equal" (all points that lie on a circle with (0,0) as center will give equality)
>>because 3+2 = 5 and 2+3 = 5 so that doesn't work
Unless you add && pt1.x==pt2.x && pt1.y==pt2.y
public int compare(Point compared)
{
long dist = x * x + y * y;
long dist2 = compared.x * compared.x + compared.y * compared.y;
if (dist == dist2)
return 0;
if (dist < dist2)
return -1;
else
return 1;
}
The issue here is that, a you pointed out, 3,2 is not 2,3 but would come out equal in this situation. This does get to be tricky, as comparison in a situation like this is probably not going to equate to being the same.
jayrod, why didn't you split the points? I was the one talking about the "distance"...
0
Featured Post
With monday.comâ€™s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.