I want to calculate the distance between two points in Java

后端 未结 7 1447
花落未央
花落未央 2020-12-29 21:31

OK, so I\'ve written most of a program that will allow me to determine if two circles overlap.

I have no problems whatsoever with my program aside from one issue: t

7条回答
  •  遥遥无期
    2020-12-29 21:55

    Math.sqrt returns a double so you'll have to cast it to int as well

    distance = (int)Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));

提交回复
热议问题