quadtree 0.1.0 copy "quadtree: ^0.1.0" to clipboard
quadtree: ^0.1.0 copied to clipboard

A simple quadtree implementation in Dart.

example/quadtree_example.dart

import 'package:quadtree/quadtree.dart';

void main() {
  // Create a quadtree with a boundary of 100x100
  final quadtree = Quadtree(Rectangle(0, 0, 100, 100));

  // Insert some points
  quadtree.insert(Point(10, 20, 'data 1'));
  quadtree.insert(Point(50, 50, 'data 2'));
  quadtree.insert(Point(80, 15, 'data 3'));

  // Query points within a range
  final pointsInRange = quadtree.query(Rectangle(0, 0, 60, 60));
  print('Points in range: ${pointsInRange.length}');

  // You can also associate data with points
  quadtree.insert(Point(25, 35, 'Some data'));

  // Retrieve points with their associated data
  final pointsWithData = quadtree.query(Rectangle(20, 30, 10, 10));
  for (var point in pointsWithData) {
    print('Point at (${point.x}, ${point.y}) with data: ${point.data}');
  }
}
0
likes
150
points
36
downloads

Publisher

unverified uploader

Weekly Downloads

A simple quadtree implementation in Dart.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on quadtree