Queries regarding ray traversing through cube using VoxelRayTracers package

Hi ,

I am trying to use VoxelRayTracers.jl. I have few doubts regarding usage of this package.

I want to trace a ray through 3D voxelized cube. My aim is to find ray intersected voxels with intersection lengths.

  1. How can I use this package with ray or line start and end points, instead of start point and velocity?
  2. How can I calculate intersection length by using entry and exit time?

Can anyone reply regarding my queries?

Thanks in Advance !
Manu

1 Like

Something like this:

  • As for your first question:
ray = (position=startpoint, velocity= endpoint - startpoint)
endtime = 1
for hit in eachtraversal(ray, edges)
    if hit.exit_time > endtime
        # endpoint might be in the middle of a voxel, handle this edge case
        break
    else
        # handle ordinary hit
    end
end
  • For your second question intersection length can be computed as follows:
(hit.exit_time - hit.entry_time) * norm(ray.velocity)
1 Like

Hi @jw3126:

Thanks a lot for your amazing reply. It is very helpful for me.
I think there is a small typo error in the answer to my second question, the intersection length may be:
norm(ray.velocity) *(hit.exit_time - hit.entry_time)

Anyway, I will play more with this package.

Thanking you,
Manu

I fixed the formula, now the units make sense.

1 Like

@jw3126: Thank you