Auios.QuadTree 1.2.0

dotnet add package Auios.QuadTree --version 1.2.0                
NuGet\Install-Package Auios.QuadTree -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Auios.QuadTree" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Auios.QuadTree --version 1.2.0                
#r "nuget: Auios.QuadTree, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Auios.QuadTree as a Cake Addin
#addin nuget:?package=Auios.QuadTree&version=1.2.0

// Install Auios.QuadTree as a Cake Tool
#tool nuget:?package=Auios.QuadTree&version=1.2.0                

Auios.QuadTree

Logo

Nuget Nuget

A Generic QuadTree algorithm inspired by Leonidovia's Ultimate QuadTree.

Wikipedia: https://en.wikipedia.org/wiki/Quadtree

Install

NuGet.org: https://www.nuget.org/packages/Auios.QuadTree/

Install-Package Auios.QuadTree

Example

// Implement IQuadTreeObjectBounds<T> interface for the object type to be stored
public class MyCustomBounds : IQuadTreeObjectBounds<Vector2> {
    public float GetBottom(Vector2 obj) => obj.Y;
    public float GetTop(Vector2 obj) => obj.Y;
    public float GetLeft(Vector2 obj) => obj.X;
    public float GetRight(Vector2 obj) => obj.X;
}

// Create a QuadTree and fill it with objects
QuadTree<Vector2> quadTree = new QuadTree<Vector2>(800, 600, new MyCustomBounds());

// Generate some data to insert
Random random = new Random();
List<Vector2> myPositions = new List<Vector2>();
for(int i = 0; i < 1000; i++) {
    myPositions.Add(new Vector2((float)800 * random.NextDouble(), (float)600 * random.NextDouble()));
}

 // Insert data into the QuadTree
foreach(Vector2 position in myPositions) {
    quadTree.Insert(myObjects);
}

// Define search area (x, y, width, height)
QuadTreeRect searchArea = new QuadTreeRect(150, 100, 50, 25);

// Find objects in leaf quadrants which overlap the search area
Vector2[] positions = quadTree.FindObjects(searchArea);

Demos

Demo3

Demo2

Demo1

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 424 9/4/2024
1.1.1 3,249 10/31/2020
1.1.0 399 10/31/2020
1.0.2 371 10/31/2020
1.0.1 412 10/31/2020
1.0.0 430 10/31/2020

1.1.0
     * Integrated Auios.Rectangle for improved rectangle handling
     * Added support for inserting collections of objects
     * Exposed the Area field for greater flexibility
     * Enhanced constructors to work seamlessly with Vector2
     * Optimized object insertion for better performance

     1.1.1
     * Refreshed logo for a better look

     1.2.0
     * Upgraded target framework from netcoreapp3.1 to net8.0