What is a good data structure for storing and searching 2d spatial coordinates in Java

后端 未结 3 1661
清酒与你
清酒与你 2021-02-07 16:03

I am currently writing a plugin for a game where one feature includes the ability to set areas defined by 2 two dimensional coordinates ( The upper left and lower right areas of

3条回答
  •  清歌不尽
    2021-02-07 16:34

    A good datastructure for determining collision in a part of space is the quad-tree datastructure. The quad-tree recursively divides a space according to the number of elements in a given area. Thus it can do a search if coordinates are inside a region in logarithmic time.

    EDIT: I have found an implementation here but no license information is given.

提交回复
热议问题