Calculating the distance between 2 points

后端 未结 7 2302
青春惊慌失措
青春惊慌失措 2020-12-17 18:37

I have two points (x1,y1) and (x2,y2). I want to know whether the points are within 5 meters of one another.

7条回答
  •  清歌不尽
    2020-12-17 19:20

    Given points (X1,Y1) and (X2,Y2) then:

    dX = X1 - X2;
    dY = Y1 - Y2;
    
    if (dX*dX + dY*dY > (5*5))
    {
        //your code
    }
    

提交回复
热议问题