Asked by Albert
on 2 Oct 2017

Dear all

Thank you for reading my following question and I greatly appreciate any of your help.

Problem: Given a grid (N*N) and a non-straight ray with known discrete coordinates, how to register the indices and path length in the pixels crossed by the ray? This is on a plane, what if it is in 3d space? Are there any existing MATLAB script to carry out this function?

Thank you very much.

Sincerely

Albert

Answer by Anton Semechko
on 26 Jun 2018

Edited by Anton Semechko
on 26 Jun 2018

Accepted Answer

For 2D reconstruction, the problem can be approached follows:

1) Let's say you have a set of K rays {Rk}, where Rk is k-th ray parameterized by the equation Rk(t)=Xk+t*Dk, where Xk is the point of origin and Dk is the direction of travel.

2) Given a M-by-M grid (G) sampled on a plane passing through point P with unit normal N, find points of intersection between G and all of the rays {Rk}.

3) Find transformation that aligns N with the z-axis, and horizonal and vertical grid lines of G with the x- and y-axes, respectively.

4) Apply the transformation from (3) to the points of intersection in (2).

5) Bin data from (4) to get the intensity image corresponding to the number of hits in a given bin (i.e., grid cell/pixel).

This process can be easily generalized to get a volumetric image using a 3D grid. This is because 3D grid is just a stack of 2D grids.

Albert
on 27 Jun 2018

Anton Semechko
on 27 Jun 2018

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 6 Comments

## Jan (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/359332-ray-tracing-indices-and-path-length-registration#comment_489323

## Albert (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/359332-ray-tracing-indices-and-path-length-registration#comment_489343

## Corey Silva (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/359332-ray-tracing-indices-and-path-length-registration#comment_490295

## Albert (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/359332-ray-tracing-indices-and-path-length-registration#comment_490300

## Alexander Jones (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/359332-ray-tracing-indices-and-path-length-registration#comment_582827

## Albert (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/359332-ray-tracing-indices-and-path-length-registration#comment_583269

Sign in to comment.