Skip to content

Go implementation of the Hilbert curve, computing distance and points

Notifications You must be signed in to change notification settings

Ganners/hilbertcurve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hilbert Curve Package

Implementation of the hilbert curve, both in conversion from coordinates (x and y) into distance, and the reverse from distance into x and y.

All functions take int64 arguments (and return likewise), this is to make the bitwise operations somewhat safer and allow for larger precision.

Install:

go get -u github.com/Ganners/hilbertcurve

Example usage:

var n int64 = 8 // 8 x 8 grid
var x int64 = 5
var y int64 = 0

// Compute the distance from the given x and y
distance := hilbertcurve.CoordinatesToDistance(n, x, y)

// Compute the x and y from our previously computed distance
cx, cy := hilbertcurve.DistanceToCoordinates(n, distance)

if x != cx || y != cy {
    log.Println("This aint good...")
}

About

Go implementation of the Hilbert curve, computing distance and points

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages