Is it possible to find the line-of-sight for coarsely spaced and uneven terrain data points?
조회 수: 2 (최근 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
답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!