Constructors

Properties

_divided: boolean

Used to know if the current instance is divided or not (branch or leaf)

_points: Point[]

The point contained in this instance

_subdivide: (() => void) = ...

Type declaration

    • (): void
    • Creates the subtrees, making the instance a branch

      Returns void

_subs: QuadTree[]
capacity: number

the points capacity

rectangle: Rectangle

the instance rectangle area

Methods

  • Inserts the given point in the instance, or to its subtrees

    Parameters

    • point: Point

      the point to insert

    Returns boolean

    true if the point is added to the instance or one of its subtrees, false if it's not

  • Queries the instance using a Rectangle object, with the given position and the given size

    Parameters

    • range: BaseRange

      the range to use for querying the tree

    • Optional check: ((particle) => boolean)

      the function to check if the particle can be added to the result

        • (particle): boolean
        • Parameters

          Returns boolean

    Returns Particle[]

    the particles inside the given range

  • Queries the instance using a Circle object, with the given position and the given radius

    Parameters

    • position: ICoordinates

      the circle position

    • radius: number

      the circle radius

    • Optional check: ((particle) => boolean)

      the function to check if the particle can be added to the result

        • (particle): boolean
        • Parameters

          Returns boolean

    Returns Particle[]

    the particles inside the given circle

  • Queries the instance using a Rectangle object, with the given position and the given size

    Parameters

    • position: ICoordinates

      the rectangle position

    • size: IDimension

      the rectangle size

    • Optional check: ((particle) => boolean)

      the function to check if the particle can be added to the result

        • (particle): boolean
        • Parameters

          Returns boolean

    Returns Particle[]

    the particles inside the given rectangle