octree

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2020 License: MIT

README

octree

Codacy Badge PkgGoDev

Imagine, someday, you lose your wallet.
You remember having it until you came back home by driving.
You will therefore search for your wallet around your car, you won't search the whole universe to find your wallet, logic no ?
That's the principle of an Octree data structure.

octree

Installation

go get -u github.com/louis030195/octree

Usage

package main

import (
    octree "github.com/louis030195/octree/pkg"
    "github.com/louis030195/protometry/api/volume"
    "log"
)

func main() {
	o := octree.NewOctree(volume.NewBoxMinMax(1, 1, 1, 4, 4, 4))
	myObj := octree.NewObjectCube(0, 2, 2, 3, 0.5)
	ok := o.Insert(*myObj)
	log.Printf("%v", ok) // true
	colliders := o.GetColliding(*volume.NewBoxMinMax(0, 0, 0, 0.9, 2.9, 0.9))
	log.Printf("%v", colliders)              // some objects
	log.Printf("%v", o.Move(myObj, 2, 2, 3)) // Success
	log.Printf("%v", o.Move(myObj, 2, 2, 8)) // Failure: outside tree !
}

Benchmark

make bench

b1 b2

Roadmap

  • More test coverage
  • Better benchmarks
  • Possible optimisations
    • Linear implementation
    • Looseness
    • Less copies, unnecessary operations
    • Parallelization of a few steps

References

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL