package oktree
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
md5=d924fe6464176f50901fd5850eaa4dc6
sha512=d1291d99105b426cbc68a1f26ea9760a5b17ddc44de2d99325dcf7a57234a7cac1d2a0837f49949604281f625c8ce2b02ae3ce2ae580611c448dbe64367e466f
Description
A simple octree implementation in OCaml, intended to efficiently find nearest match for an arbitrary point among a set of points in 3D coordinate space.
Added to opam-repository:
README
OKtree
[ Docs ]
OKtree is a simple octree implementation in OCaml, intended to efficiently find the nearest match for an arbitrary point among a set of target points in 3D coordinate space.
The original use case for this lib was finding nearest match in a palette of RGB colours.
- Aims to be faster than not using an octree, does not claim to be world's fastest octree.
- Fast insertions are not a goal. Use-case is: create a tree once, match points many times.
Basic usage
A tree is generated from a list of 3D points.
OKtree defines a VEC3 module type for the points. This is deliberately compatible with the Gg library's Gg.V3 module type.
So first we instantiate the Oktree functor, then add points:
open Gg
module Okt = Oktree.Make (V3)
let points = [ V3.zero; V3.v 0. 0.251 0.; V3.v 0. 0.23 0.; V3.v 0.2 0.1 0.2 ]
let okt = Okt.of_list ~leaf_size:8 points
Format.printf "%a" Okt.pp okt;;
(*
{ Oktree.Make.leaf_size = 8;
tree =
(Oktree.Make.Leaf
[(0.000000, 0.000000, 0.000000); (0.000000, 0.251000, 0.000000);
(0.000000, 0.230000, 0.000000); (0.200000, 0.100000, 0.200000)])
}- : unit = ()
*)
(* find closest match from [points] *)
let nearest = Okt.nearest okt (V3.v 0.2 0.1 0.3)
Format.printf "%a" V3.pp nearest;;
(* (0.2 0.1 0.2)- : unit = () *)Interface:
Okt.of_listbuilds a tree from list of points;~leaf_sizecontrols max points per leaf before splitting (optional, default:16).Okt.nearestfinds the closest point in the tree to a given query point.Okt.insertreturns a new tree with the point added.Okt.to_listreturns list of points in tree.Okt.ppis a printer of trees, for use withFormat.printfand friends.
Dependencies (3)
- ppx_deriving
-
ocaml
>= "4.14" -
dune
>= "3.6"
Dev Dependencies (15)
-
odoc
with-doc -
utop
with-dev-setup -
landmarks-ppx
with-dev-setup -
landmarks
with-dev-setup -
core_unix
with-dev-setup & >= "v0.15.0" -
core_bench
with-dev-setup & >= "v0.15.0" -
ocaml-lsp-server
with-dev-setup -
opam-publish
with-dev-setup -
ocp-indent
with-dev-setup -
ocamlformat
with-dev-setup -
gg
with-test & >= "1.0" -
junit_alcotest
with-test & >= "2.0" -
alcotest
with-test & >= "1.7.0" -
qcheck-alcotest
with-test & >= "0.21" -
qcheck-core
with-test & >= "0.21"
Optional Dependencies (1)
Used by (1)
Conflicts
None
Build status
Results of building oktree with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.2.4 (this version) | n/a | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure