Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

Using Composer, just add it to your composer.json by running:

composer require josue/spatial-hash-table

Description

You can throw edges and points at it and than make fast proximity queries in a fixed radius (set in the constructor).

Usage

Example

Alt Test case graph

<?php

use SpatialHashTable\BiHashTable;
use SpatialHashTable\SupportedGeometries\Edge;
use SpatialHashTable\SupportedGeometries\Point;

$b = new BiHashTable(1);

$b->addElement(new Edge(new Point(-1.5, -1), new Point( -0.5, -0.5), 100));
$b->addElement(new Edge(new Point(1.25, 1.5), new Point( 0.5, 0.75), 200));
$b->addElement(new Edge(new Point(1.75, 1.75), new Point( 1.75, 1.25), 300));
$b->addElement(new Point(0.5, 0.5, 400));


echo json_encode($b->getAllElementsInCircle(new Point(0,0)));

And the output is:

{
  "100": {
    "id": 100,
    "p1": {
      "id": 0,
      "x": -1.5,
      "y": -1
    },
    "p2": {
      "id": 0,
      "x": -0.5,
      "y": -0.5
    }
  },
  "200": {
    "id": 200,
    "p1": {
      "id": 0,
      "x": 1.25,
      "y": 1.5
    },
    "p2": {
      "id": 0,
      "x": 0.5,
      "y": 0.75
    }
  },
  "400": {
    "id": 400,
    "x": 0.5,
    "y": 0.5
  }
}

About

2D hash table for fast edges-or-points-touching-circle retrieval

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages