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

1 次查看(过去 30 天)
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 个评论
Matt J
Matt J 2024-8-15
编辑:Matt J 2024-8-15
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 2024-8-16
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.

请先登录,再进行评论。

回答(1 个)

Matt J
Matt J 2024-8-16
编辑:Matt J 2024-8-16
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 个评论
Brian
Brian 2024-8-16
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 2024-8-16
编辑:Matt J 2024-8-16
I don't think I understand the question. The code doesn't know anything about "vision cells". It works with lines and line segments.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by