spherical-volume-rendering / svr-algorithm

A spherical volume rendering algorithm that performs ray casting through a spherical voxel grid.
Other
6 stars 7 forks source link

Ray collinear with voxel boundary. #101

Closed cgyurgyik closed 4 years ago

cgyurgyik commented 4 years ago
TEST(SphericalCoordinateTraversal, RayTravelsAlongXAxis) {
        const BoundVec3 min_bound(0.0, 0.0, 0.0);
        const BoundVec3 max_bound(30.0, 30.0, 30.0);
        const BoundVec3 sphere_center(0.0, 0.0, 0.0);
        const double sphere_max_radius = 10.0;
        const std::size_t num_radial_sections = 4;
        const std::size_t num_angular_sections = 8;
        const std::size_t num_azimuthal_sections = 4;
        const SphericalVoxelGrid grid(min_bound, max_bound, num_radial_sections,
                                      num_angular_sections,
                                      num_azimuthal_sections, sphere_center, sphere_max_radius);
        const BoundVec3 ray_origin(-15.0, 0.0, 0.0);
        const FreeVec3 ray_direction(1.0, 0.0, 0.0);
        const Ray ray(ray_origin, ray_direction);
        const double t_begin = 0.0;
        const double t_end = 30.0;

        const auto actual_voxels = sphericalCoordinateVoxelTraversal(ray, grid, t_begin, t_end);
        const std::vector<int> expected_radial_voxels = {1,2,3,4,4,3,2,1};
        const std::vector<int> expected_theta_voxels = {4,4,4,4,5,5,5,5};
        const std::vector<int> expected_phi_voxels = {2,2,2,2,3,3,3,3};
        expectEqualVoxels(actual_voxels, expected_radial_voxels, expected_theta_voxels, expected_phi_voxels);
    }

This is the correct theta voxels: expected_theta_voxels = {4,4,4,4,7,7,7,7};

Parallel lines are not intersections in our current implementation. In this case though, they are parallel and collinear.

We may want to consider that collinear lines are intersecting. The issue with this is that intersection will occur at EACH step of the traversal.