Hierarchy

  • QuadTree

Constructors

  • Initializes the instance with a rectangle and a capacity

    Parameters

    • rectangle: Rectangle

      the instance rectangle area

    • capacity: number

      the points capacity

    Returns QuadTree

Properties

capacity: number
divided: boolean

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

northEast?: QuadTree

The NE subtree

northWest?: QuadTree

the NW subtree

points: Point[]

The point contained in this instance

rectangle: Rectangle
southEast?: QuadTree

the SE subtree

southWest?: QuadTree

the SW subtree

Methods

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

    Returns

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

    Parameters

    • point: Point

      the point to insert

    Returns boolean

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

    Returns

    the particles inside the given range

    Parameters

    • range: Range

      the range to use for querying the tree

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

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

    • Optional found: Particle[]

      found particles array, output parameter

    Returns Particle[]

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

    Returns

    the particles inside the given circle

    Parameters

    • position: ICoordinates

      the circle position

    • radius: number

      the circle radius

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

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

    Returns Particle[]

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

    Returns

    the particles inside the given circle

    Parameters

    • position: ICoordinates

      the circle position

    • radius: number

      the circle radius

    • containerOrSize: IDimension | Container

      the container canvas size

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

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

    Returns Particle[]

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

    Returns

    the particles inside the given rectangle

    Parameters

    • position: ICoordinates

      the rectangle position

    • size: IDimension

      the rectangle size

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

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

    Returns Particle[]

  • Creates the subtrees, making the instance a branch

    Returns void