Clear Filters
Clear Filters

Is it possible to find the line-of-sight for coarsely spaced and uneven terrain data points?

25 views (last 30 days)
Thank you for taking the time to help me with this. I'm using MATLAB R2024a. Here is my code:
% Create coarse-uneven data points
Xc = [5 7 11 17 27 40 59 82 129 191];
Yc = [-5 -2 2 0 3 -4 0 4 0 7];
% Basic parameters for observer and lines-of-sight
height = 5.2;
distance = 200;
radians = -pi/4:pi/24:0;
% Coordinates for intersecting lines
[X2, Y2] = pol2cart(radians, distance);
Y2 = Y2 + height;
X1 = zeros(size(X2));
Y1 = zeros(size(Y2)) + height;
% Plotting
figure
plot(Xc, Yc, '-r')
hold on
plot([X1; X2], [Y1; Y2], '-b')
hold off
As you can see, the x-component of the terrain is coarse and unevenly spaced. I would like to identify which terrain datapoints (Xc and Yc) are within line-of-sight of each "slice" of the observer's vision. In the attached picture, there are four data points within the first sector of vision. It is likely that the second data point and most certainly the fourth data point would be obscured by the terrain pattern. How can I caluclate the line-of-sight for this and extract the Xc components that fall within line of sight of the observer who is positioned at x=0 and y=height?
Ideally, the output would be an NxM logical array where N is the number of vision sectors and M is the length of Xc. The values contained along M in the matrix would represent with boolean true/false values the indices of Xc in which (Xc,Yc) is visible by the observer for the Nth vision sector.
From what I've seen, los() and los2() take inputs in a much different format than just 2-D cartesian points and lines, so I haven't been able to figure it out using those functions.
Once again, thank you for your time.
  2 Comments
Matt J
Matt J on 15 Aug 2024 at 22:19
Edited: Matt J on 15 Aug 2024 at 22:20
It is likely that the second data point and most certainly the fourth data point would be obscured by the terrain pattern.
Why? How is that tested?
Brian
Brian on 16 Aug 2024 at 14:46
Hi Matt J, thanks for answering. My hypothesis is not tested. I assume the second and fourth data points in the picture attached will be self-occluded by the other peaks in the terrain, however, this is what I am trying to do is figure out how to verify, through calculating the line of sight.

Sign in to comment.

Answers (1)

Matt J
Matt J on 16 Aug 2024 at 14:54
Edited: Matt J on 16 Aug 2024 at 14:56
You coulduse linexline2d from this FEX post,
It lets you solve for the intersection of one line segment with batches of other line segments. If the line of sight line segment has an intersection with any of the other line segments that make up the terrain, it indicates an occlusion.
  2 Comments
Brian
Brian on 16 Aug 2024 at 15:49
I'm looking through your function and example.mlx in MATLAB online now. Do you think in my case it would handle the line segments out of view of each "vision cell" as arbitrary, thus producing a NaN? I ask because I believe it could be an issue as the spacing between data points gets more coarse and uneven as the range increases. I would need a way to round to these data points instead of discarding them to get the best guess on which data points are included in the line-of-sight.
Matt J
Matt J on 16 Aug 2024 at 16:43
Edited: Matt J on 16 Aug 2024 at 16:58
I don't think I understand the question. The code doesn't know anything about "vision cells". It works with lines and line segments.

Sign in to comment.

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!