フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to get the points on line or points which certain distance from the line

1 回表示 (過去 30 日間)
NS
NS 2017 年 11 月 1 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have 3D matrix file where XYZ are lon,lat and height. I plot these XYZ value using scatter3. Now I want to plot profile of height (along a line in km) of the data where xaxis:distance along line in km and yaxis:Z value.In this case points (Z value) on the line for specific x and y value distance from the line will pick up for profile plot. I wrote the below code to do that but could not specify value for x and y limit to pick up the points on line and the points of certain distance from the line horizontally and vertically.
X_start=-7.32;%starting X point for line A
Y_start=5.08;%starting Y point for line A
X_end=-7.23;%ending X point for line A'
Y_end=5.31;%ending Y point for line A'
X_h=-7.32;%X point to specify Horizontal distance
Y_h=5.09;%Y point to specify Horizontal distance
m=(Y_end-Y_start)./(X_end-X_start);%slope/gradient between Star and Ending point
b=Y_start-m*X_start;%intercept of Y
x=[X_start,X_end];
y=m*x+b;
%distance specify horizontally
d_h=sqrt((X_start-X_h)^2+(Y_start-Y_h)^2);%Specify the distance Horizontally
t=d_h;
v_X = (linspace(X_start,X_end,t))';%Line X
v_Y = (linspace(Y_start,Y_end,t))';%Line Y
F = scatteredInterpolant(X,Y,Z);%Scatter interpolation
v_Z=F(v_X,v_Y);%Finding query Z
% distacne calculation from Starting to Ending Point
v_X_ref=v_X(1,:);%Set first X point A as reference
v_X_ref=v_Y(1,:);%Set first Y point A as reference
for i=1:length(v_X)
n=v_X(i,:);
e=v_Y(i,:);
d(:,i)=(sqrt((v_X_ref-e)^2+(v__ref-n)^2))/1000;
end
Please help me to solve this. Thank you!
  7 件のコメント
NS
NS 2017 年 11 月 2 日
Thanks for the response. This there are actual value. I select the X_start and y_start, X_end and Y_end like (X1,Y1) and (X2,Y2) to create line on the XYZ scatter plot.
Vaidyanathan Thiagarajan
Vaidyanathan Thiagarajan 2017 年 11 月 3 日
Hi,
I am also getting the same error as above. Can you please post the full code?
I am not sure what is your question. However, it looks like you are trying to do some basic geometric operations with points and lines.
To sample points on a line, you can follow the ideas in this post :
To check if a point is on a given line segment, you can follow the ideas in this post :
To compute the shortest distance between a line and point, you follow the solution in this post :
Hope it helps!
Best Regards,
Vaidyanathan

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by