Finding all the points within a circle in 2D space

前端 未结 7 1777
自闭症患者
自闭症患者 2021-02-13 12:58

I am representing my 2D space (consider a window), where each pixel is shown as a cell in a 2D array. i.e. a 100x100 window is represented by the array of same dimensions.

7条回答
  •  抹茶落季
    2021-02-13 13:58

    If the following is true:

    ( ( xPos - centreX)^2 + (yPos - centreY)^2 ) <= radius^2
    

    where xPos and yPos are the coordinates of a point you're checking, then the point is inside your circle.

提交回复
热议问题