field.kit.math.geometry

Quadtree

class Quadtree extends AABR

Implements a spatial subdivision tree to work efficiently with large numbers of 2D particles.

Inherits

  1. AABR
  2. Vec2
  3. Vec
  4. AnyRef
  5. Any

Value Members

  1. def apply(circle: Circle, result: ArrayBuffer[Vec]): ArrayBuffer[Vec]

    Selects all stored points within the given sphere volume

    Selects all stored points within the given sphere volume

  2. def apply(box: AABR, result: ArrayBuffer[Vec]): ArrayBuffer[Vec]

    Selects all stored points within the given axis-aligned bounding box

    Selects all stored points within the given axis-aligned bounding box.

    box

    AABB

    result

    the ArrayBuffer

    returns

    all points with the box volume

  3. var children: Array[Quadtree]

    Stores the child nodes of this node

    Stores the child nodes of this node

  4. def clear: Unit

    Clears all children and data of this node

    Clears all children and data of this node

  5. def clone(): Vec2

    This method creates and returns a copy of the receiver object

    This method creates and returns a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    definition classes: Vec2 ⇐ AnyRef
  6. def contains(p: Vec): Boolean

    definition classes: AABR
  7. val depth: Int

  8. def equals(arg0: Any): Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    The default implementations of this method is an equivalence relation:

    • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
    • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
    • It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

    If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects that are "equal" (o1.equals(o2) returns true) hash to the same Int (o1.hashCode.equals(o2.hashCode)).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    definition classes: AnyRef ⇐ Any
  9. var extent: Vec2

  10. val halfSize: Vec2

  11. def hashCode(): Int

    Returns a hash code value for the object

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

    definition classes: AnyRef ⇐ Any
  12. def height: Float

    definition classes: AABR
  13. def height_=(value: Float): Unit

  14. def insert(p: Vec): Boolean

    Adds a new point/particle to the tree structure

    Adds a new point/particle to the tree structure. All points are stored within leaf nodes only. The tree implementation is using lazy instantiation for all intermediate tree levels.

    p
    returns

    true, if point has been added successfully

  15. def intersects(center: Vec, radius: Float): Boolean

    definition classes: AABR
  16. def intersects(circle: Circle): Boolean

    definition classes: AABR
  17. def intersects(rect: AABR): Boolean

    definition classes: AABR
  18. def leafForPoint(p: Vec2): Quadtree

    Alias for apply(p:Vec2)

    Alias for apply(p:Vec2)

  19. var max: Vec2

  20. var maxNeighbours: Int

  21. var min: Vec2

  22. var minSize: Float

    Alternative tree recursion limit, number of world units when cells are not subdivided any further

    Alternative tree recursion limit, number of world units when cells are not subdivided any further

  23. var numChildren: Int

    the number of child nodes (max

    the number of child nodes (max. 4)

  24. val offset: Vec2

  25. val parent: Quadtree

  26. def pointsWithinBox(rect: AABR, result: ArrayBuffer[Vec]): ArrayBuffer[Vec]

    Alias for apply(rect:AABR, result:ArrayBuffer[Vec])

    Alias for apply(rect:AABR, result:ArrayBuffer[Vec])

  27. def pointsWithinCircle(circle: Circle, result: ArrayBuffer[Vec]): ArrayBuffer[Vec]

    Alias for apply(circle:Circle, result:ArrayBuffer[Vec])

    Alias for apply(circle:Circle, result:ArrayBuffer[Vec])

  28. def remove(p: Vec2): Boolean

    Removes a point from the tree and (optionally) tries to release memory by reducing now empty sub-branches

    Removes a point from the tree and (optionally) tries to release memory by reducing now empty sub-branches.

    p

    point to delete

    returns

    true, if the point was found & removed

  29. val size: Vec2

  30. def toCartesian: Unit

    Converts the vector from polar to Cartesian space

    Converts the vector from polar to Cartesian space. Assumes this order: x=radius, y=theta

    definition classes: Vec2
  31. def toLabel: String

  32. def toPolar: Vec2

    Converts the current vector into polar coordinates

    Converts the current vector into polar coordinates. After the conversion the x component of the vector contains the radius (magnitude) and y the rotation angle.

    definition classes: Vec2
  33. def toString(): String

    Returns a string representation of the object

    Returns a string representation of the object.

    The default representation is platform dependent.

  34. def updateBounds: Unit

  35. def width: Float

    definition classes: AABR
  36. def width_=(value: Float): Unit

  37. var x: Float

  38. var y: Float

  39. def z: Float

  40. def z_=(value: Float): Unit

Instance constructors

  1. new Quadtree(parent: Quadtree, offset: Vec2, halfSize: Vec2, minSize: Float, maxNeighbours: Int)

  2. new Quadtree(parent: Quadtree, offset: Vec2, halfSize: Vec2)

  3. new Quadtree(position: Vec2, extent: Vec2)

  4. new Quadtree(extent: Vec2)

  5. new Quadtree()

  6. new Quadtree(x: Float, y: Float)