-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathraycasting.h
34 lines (25 loc) · 1.02 KB
/
raycasting.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef _RAYCASTING_H_
#define _RAYCASTING_H_
#include <Eigen/Eigen>
#include <vector>
#include <cmath>
/*
RayCasting2D and RayCasting3D are based on Amanatides & Woo ray tracing algorithm.
Their paper "A Fast Voxel Traversal Algorithm for Ray Tracing" can be found here:
<https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.42.3443&rep=rep1&type=pdf>
This algorithm uses a parameterized line equation for ray tracing.
Ray equation: r = r0 + t*v, where r0 is the ray origin, v is difference between ray end and ray origin.
E.g: X0 = [0.5 0.5], X1 = [2.5 0]
Then, v = [2 -0.5]
r = [0.5 0.5] + t * [2 -0.5]
*/
void RayCasting2D(const Eigen::Vector2d& ray_origin, const Eigen::Vector2d& ray_end,
std::vector<Eigen::Vector2d>& traversed_voxels);
void RayCasting3D(const Eigen::Vector3d& ray_origin, const Eigen::Vector3d& ray_end,
std::vector<Eigen::Vector3d>& traversed_voxels);
/*void RayCastingBresenham()
{
//TODO
}
*/
#endif //_RAYCASTING_H_