Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/d3-quadtree

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/d3-quadtree

TypeScript definitions for d3-quadtree

  • 1.0.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4M
decreased by-14.94%
Maintainers
1
Weekly downloads
 
Created

What is @types/d3-quadtree?

@types/d3-quadtree provides TypeScript type definitions for the d3-quadtree module, which is part of the D3.js library. The d3-quadtree module is used for efficient spatial indexing of 2D points, allowing for fast querying of points within a given area. This is particularly useful for tasks such as collision detection, nearest neighbor search, and spatial clustering.

What are @types/d3-quadtree's main functionalities?

Creating a Quadtree

This feature allows you to create a new quadtree instance. A quadtree is a data structure that partitions a two-dimensional space by recursively subdividing it into four quadrants or regions.

const quadtree = d3.quadtree();

Adding Points to the Quadtree

This feature allows you to add a point to the quadtree. The point is specified as a two-element array [x, y], where x and y are the coordinates of the point.

quadtree.add([x, y]);

Finding the Closest Point

This feature allows you to find the closest point in the quadtree to a given point (x, y). This is useful for nearest neighbor search.

const closest = quadtree.find(x, y);

Removing Points from the Quadtree

This feature allows you to remove a point from the quadtree. The point to be removed is specified as a two-element array [x, y].

quadtree.remove([x, y]);

Querying Points within a Bounding Box

This feature allows you to query all points within a specified bounding box. The visit method is used to traverse the quadtree and collect points that fall within the bounding box.

const points = []; quadtree.visit((node, x0, y0, x1, y1) => { if (!node.length) { do { const d = node.data; if (d[0] >= x0 && d[0] < x1 && d[1] >= y0 && d[1] < y1) { points.push(d); } } while (node = node.next); } return x0 >= x1 || y0 >= y1; });

Other packages similar to @types/d3-quadtree

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc