Git Product home page Git Product logo

voxel-traversal's Introduction

Voxel Traversal

Build Status License: MIT

voxel traversal cover image

A small library to compute voxel traversal on the CPU. The implemented algorithm is J. Amanatides, A. Woo: "A Fast Voxel Traversal Algorithm". It is based on the code prototype of Chris Gyurgyik Fast-Voxel-Traversal-Algorithm.

The contributions of this repository are:

  • Tests!
  • Python bindings (in progress...)
  • Installation and cmake packaging
  • Use Eigen for readability, vectorization, and grid counting.
  • Execution and timing on real LiDAR data from the nuScenes dataset. The demonstration data files are bundled with git lfs.

Requirements and Dependencies

  • Eigen3
  • C++17 compiler

Python bindings

# setup python environment, make cmake >= 3.21 available, e.g. with conda install cmake=3.22
$ python setup.py install
# or
$ python setup.py develop
$ pytest tests

Run the Tests and Install

$ git clone https://github.com/risteon/voxel-traversal.git
$ mkdir build && cd build
# set CMAKE_INSTALL_PREFIX to your liking
# specify python version with -DPYTHON_EXECUTABLE=<path/to/python> or -DPYBIND11_PYTHON_VERSION=3.XX
$ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install ..
# build and install
$ cmake --build . --target install -- -j 4
# run tests
$ ctest

Find with cmake & Usage

Your project's CMakeLists.txt:

cmake_minimum_required(VERSION 3.21)
project(your_project)
set(CMAKE_CXX_STANDARD 17)

find_package(Eigen3 3.3 REQUIRED NO_MODULE)
find_package(VoxelTraversal REQUIRED)

add_executable(your_executable main.cpp)
target_link_libraries(your_executable VoxelTraversal::VoxelTraversal)

When configuring, set CMAKE_PREFIX_PATH to this project's install directory.

Code example:

#include <VoxelTraversal/voxel_traversal.h>

using namespace voxel_traversal;

// types for vectors and indices
using V3 = typename Grid3DSpatialDef<double>::Vector3d;
using C3 = typename Grid3DSpatialDef<double>::Index3d;
using R = Ray<double>;

const V3 bound_min(0.0, 0.0, 0.0);
const V3 bound_max(2.0, 2.0, 2.0);
const C3 voxel_count(2, 2, 2);
Grid3DSpatialDef<double> grid(bound_min, bound_max, voxel_count);
// use this subclass to count traversed voxels
Grid3DTraversalCounter<double> grid_counter(bound_min, bound_max, voxel_count);

// Ray
const auto ray = R::fromOriginDir({.5, .5, .5}, {1., 0., 0.});

// determine which voxels are traversed (in order from origin to end)
TraversedVoxels<TypeParam> traversed{};
const auto does_intersect = traverseVoxelGrid(ray, grid, traversed);
// count traversed voxels
traverseVoxelGrid(ray, grid_counter);

voxel-traversal's People

Contributors

risteon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

zlewe

voxel-traversal's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.