You need to specify a zone when creating the quadtree, which will be the zone corresponding to the root node. Each subdivision cut the space in 4 equal regions from the center of the parent node.
geometry :: SQuadTree :: defaultinit
core :: Collection :: CONCURRENT
Type of the concurrent variant of this collectionserialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePackserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Collection :: combinations
Allr
-length combinations on self (in same order) without repeated elements.
core :: Collection :: combinations_with_replacement
Allr
-length combination on self (in same order) with repeated elements.
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
core :: SimpleCollection :: defaultinit
core :: Collection :: defaultinit
geometry :: SQuadTree :: defaultinit
geometry :: QuadTree :: defaultinit
core :: Object :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
core :: Collection :: has_all
Does the collection contain at least each element ofother
?
core :: Collection :: has_any
Does the collection contain at least one element ofother
?
core :: Collection :: has_exactly
Does the collection contain exactly all the elements ofother
?
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
geometry :: QuadTree :: item_limit
Maximum number of items in this node before subdividinggeometry :: QuadTree :: item_limit=
Maximum number of items in this node before subdividinggeometry :: BoxedCollection :: items_overlapping
returns all the items overlapping withregion
serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: output_class_name
Display class name on stdout (debug only).geometry :: QuadTree :: parent_node
Parent node in the treegeometry :: QuadTree :: parent_node=
Parent node in the treecore :: Collection :: permutations
Allr
-length permutations on self (all possible ordering) without repeated elements.
core :: Collection :: product
Cartesian product, overr
times self
.
core :: RemovableCollection :: remove
Remove an occurrence ofitem
core :: RemovableCollection :: remove_all
Remove all occurrences ofitem
serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
core :: Collection :: to_concurrent
Wrapsself
in a thread-safe collection
core :: Collection :: to_counter
Create and fill up a counter with the elements of `self.core :: Collection :: to_curlslist
Convert Collection[String] to CURLSListserialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
core :: Collection :: to_shuffle
Return a new array made of elements in a random order.geometry :: QuadTree :: with_parent
Create a child node toparent
Serializer::serialize
# Static implementation of the quadtree structure
#
# You need to specify a zone when creating the quadtree,
# which will be the zone corresponding to the root node.
# Each subdivision cut the space in 4 equal regions from
# the center of the parent node.
class SQuadTree[E: Boxed[Numeric]]
super QuadTree[E]
# Width of this node of the QuadTree
var width: Numeric
# Height of this node of the QuadTree
var height: Numeric
init
do
center = new Point[Numeric](width.div(2), height.div(2))
end
# Create a child node to `parent`
init with_parent(l: Int, c: Point[Numeric], w, h: Numeric, parent: QuadTree[E])
do
init(l, w, h)
center = c
self.parent_node = parent
end
redef fun subdivide
do
var center = center
assert center != null
children[0] = new SQuadTree[E].with_parent(self.item_limit, new Point[Numeric](center.x.div(2), center.y.div(2)), self.width.div(2), self.height.div(2), self)
children[1] = new SQuadTree[E].with_parent(self.item_limit, new Point[Numeric](center.x.div(2), (center.y.mul(3)).div(2)), self.width.div(2), self.height.div(2), self)
children[2] = new SQuadTree[E].with_parent(self.item_limit, new Point[Numeric]((center.x.mul(3)).div(2), (center.y.mul(3)).div(2)), self.width.div(2), self.height.div(2), self)
children[3] = new SQuadTree[E].with_parent(self.item_limit, new Point[Numeric]((center.x.mul(3)).div(2), center.y.div(2)), self.width.div(2), self.height.div(2), self)
end
redef fun to_s
do
var s = "center : {center or else "null"}\n"
for d in data do s += d.to_s
if children.not_empty then
s += "\n children[0]: {children[0]}\n"
s += " children[1]: {children[1]}\n"
s += " children[2]: {children[2]}\n"
s += " children[3]: {children[3]}\n"
end
return s
end
end
lib/geometry/quadtree.nit:227,1--279,3