g-andrade
erlquad - quadtrees for the BEAM
erlquad provides Erlang quadtrees, a 2D spatial index that recursively subdivides a rectangular region into four quadrants, so that objects can be looked up by location without scanning them all.
Today I revived this library, after I had archived it in 2019. Since I had never announced it in this forum, this is my first post about it.
Use cases
Good for many things in 2D.
- Collision detection: find nearby candidates instead of every pair
- Viewport culling: grab only what’s on screen
- Maps: pins within the current bounds
- Proximity: who/what’s near a point
- Hit-testing: what’s under the click
- Partitioning many actors: bucket lots of entities by region
Example
A 100x100 world, 4 levels deep, holding a few points.
Each object == its coordinate, so the outline function returns the object itself.
points = [{10, 10}, {90, 90}, {12, 15}]
outline_fun = fn p -> p end
q = :erlquad.objects_add(points, outline_fun, :erlquad.new(0, 0, 100, 100, 4))
“What’s in the bottom-left corner?”
:erlquad.area_query(0, 0, 20, 20, q)
# [{10, 10}, {12, 15}]
^ The far-off {90,90} isn’t looked at.
Links
Popular in Announcing
Hi everyone,
I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
import Meeseeks.CSS
html = HTTPoison.get!("https://news.ycombinator.com/").body
for story <- Meeseeks.all(html, css("tr.athing")) do...
New
Only 650 LOC, wrote for fun :slight_smile:
https://github.com/sunboshan/qrcode
New
Could not wait for the missing Elixir ML libraries to appear, so, I wrote one myself, taking https://github.com/sdwolfz/exlearn as a foun...
New
Hello :waving_hand:
Allow me to introduce you to Tz, an alternative time zone database support to Tzdata.
Why another library?
First a...
New
Dear Elixir community,
After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components.
We also have a boi...
New
Hello everybody :wave:
Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New
Bandit is an HTTP server for Plug and WebSock apps.
Bandit is written entirely in Elixir and is built atop Thousand Island. It can serve...
New
I’m excited to announce Jido, a framework providing foundational primitives for building autonomous agent systems in Elixir. While develo...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something…
Haskell reminds me of Java, and e...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
Got a question about when to concat vs. prepending items to list then reversing to achieve appending.
So i know lists boil down to [1 | ...
New
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









