The center of the parent node is determined by the average
values of the data it contains when item_limit
is reached.
core :: Collection :: CONCURRENT
Type of the concurrent variant of this collectiongeometry :: QuadTree :: _item_limit
Maximum number of items in this node before subdividinggeometry :: QuadTree :: _parent_node
Parent node in the treeserialization :: Serializable :: accept_inspect_serializer_core
serialization :: 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
geometry :: QuadTree :: add_to_children
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
geometry :: DQuadTree :: defaultinit
core :: Object :: defaultinit
geometry :: QuadTree :: defaultinit
core :: Collection :: 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
geometry :: QuadTree :: items_overlapping_in
var dquadtree = new DQuadTree[Point[Int]](2)
serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: native_class_name
The class name of the object in CString format.core :: 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
serialization :: Serializable :: serialize_to_or_delay
Accept references or force direct serialization (usingserialize_to
)
core :: Collection :: serialize_to_pure_json
Utility to serialize a normal Json arraycore :: 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
# A dynamic implementation of the quadtree data structure
#
# The center of the parent node is determined by the average
# values of the data it contains when `item_limit` is reached.
class DQuadTree[E: Boxed[Numeric]]
super QuadTree[E]
redef fun subdivide
do
self.center = new Point[Numeric](average_x, average_y)
children[0] = new DQuadTree[E].with_parent(self.item_limit, self)
children[1] = new DQuadTree[E].with_parent(self.item_limit, self)
children[2] = new DQuadTree[E].with_parent(self.item_limit, self)
children[3] = new DQuadTree[E].with_parent(self.item_limit, self)
end
# Average X coordinate of the items in this node
fun average_x: Numeric
do
var x_total = data.first.left.zero
for data in self.data do
x_total += (data.left + data.right)/x_total.value_of(2)
end
return x_total/x_total.value_of(self.data.length)
end
# Average Y coordinate of the items in this node
fun average_y: Numeric
do
var y_total = data.first.left.zero
for data in self.data do
y_total += (data.left + data.right)/y_total.value_of(2)
end
return y_total/y_total.value_of(self.data.length)
end
end
lib/geometry/quadtree.nit:190,1--225,3