Sagar
Sagar

Reputation: 165

How to find all the grid points between two grid point in Matlab

I have profile (function) in MatLab and now I want to find all the grid points between a point on the profile and on a source line (another line on top of my profile), so that I can check the value of my function at those grid points.

Basically I need to find the visibility angle (the angle which is visible from a point on my profile of the source).

Please help !

Thanks in advance

What I want to do is that given two grid points which can be joined by a straight line, I want to know the index of the grid points lying on that line. Somehow I need to know through which all grid points, the line passes throug

Upvotes: 3

Views: 2896

Answers (1)

Patashu
Patashu

Reputation: 21793

Finding all places on a grid that are in a straight line between two points simply requires you to use a line drawing algorithm, such as http://en.wikipedia.org/wiki/Bresenham's_line_algorithm .

In MatLab this can be implemented by using the function given here

http://www.mathworks.com/matlabcentral/fileexchange/28190-bresenham-optimized-for-matlab/content/bresenham.m

Developed by Aaron Wetzler.

Upvotes: 1

Related Questions