Skip to content

louis030195/octree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Dynamic sparse bounded octree in Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors