how to plot a plane using equations of planes?

69 ビュー (過去 30 日間)
Sierra
Sierra 2022 年 6 月 21 日
コメント済み: Sai Charan Sampara 2022 年 6 月 23 日
I want to plot a plane using normal vecotr which is perpendicular to a plane.
my data is lon,lat,alt data(3D).
I used this code to plot a plane to which normal vector is perpendicular.
A = mean_trajectory(1).Longitude - mean_trajectory(2).Longitude;
B = mean_trajectory(1).Latitude - mean_trajectory(2).Latitude;
C = mean_trajectory(1).Altitude - mean_trajectory(2).Altitude;
D = -(A*mean_trajectory(2).Longitude + B*mean_trajectory(2).Latitude + C*mean_trajectory(2).Altitude);
x1 = linspace(126.6042,126.5995,10); % I manually limited the x axis and y axis.
y1 = linspace(37.2995,37.3048,10);
[x y] = meshgrid(x1,y1);
z = -1./C * (A.*x + B.*y + D);
surf(x,y,z)
but the result seems to be something wrong especially the 'z' value(alt).
I think it should be slightly titled. but it's not.
I draw what i want to make for your understanding.
left is what i want to draw and right is what i plotted so far.
If you more clarficiation, just tell me
Thanks!

採用された回答

Karim
Karim 2022 年 6 月 22 日
編集済み: Karim 2022 年 6 月 22 日
does this result in what you need?
Edit: update to plot a plane at each point and plot the normal using quiver
XYZ = [ 126.6041 37.2994 3.3584e+3;
126.5994 37.3047 3.2463e+3;
126.5946 37.3101 3.1241e+3;
126.5898 37.3155 2.9994e+3;
126.5850 37.3208 2.8738e+3;
126.5802 37.3262 2.7481e+3];
MyNormals = XYZ(2:end,:) - XYZ(1:end-1,:);
MyNormals = MyNormals ./ repmat(sqrt(sum(MyNormals.^2,2)),1,3);
% plot the normals
figure
hold on
scatter3(XYZ(:,1), XYZ(:,2), XYZ(:,3),'r','filled')
quiver3(XYZ(1:end-1,1),XYZ(1:end-1,2),XYZ(1:end-1,3),MyNormals(:,1),MyNormals(:,2),MyNormals(:,3),0.2,'MaxHeadSize',0.01)
% create local x and y
gridPoints = linspace(-1,1,10);
[xx,yy] = ndgrid(gridPoints,gridPoints);
for i = 1:(size(XYZ,1)-1)
% calculate corresponding z
xv = XYZ(i,1) + xx;
yv = XYZ(i,2) + yy;
zv = (dot(MyNormals(i,:),XYZ(i,:)) - MyNormals(i,1).*xv - MyNormals(i,2).*yv) ./ MyNormals(i,3);
% plot the plane
surf(xv,yv,zv)
end
hold off
view(3)
axis tight
grid on
xlabel('longitude')
ylabel('latitude')
zlabel('altitude')
view([-43 5])
  5 件のコメント
Sierra
Sierra 2022 年 6 月 22 日
Thanks ! KASR
I finally plotted the plane made from mean trajectory using your code, and I plotted every trajectory(other aircraft).
but the plane is so big that I cannot see well.
do you know how to define the size of plane? or is it already in your code?
Thanks again.
Sierra
Sierra 2022 年 6 月 22 日
and I don't understand this code. could you explan it to me?
Have a good day KASR
MyNormals = MyNormals ./ repmat(sqrt(sum(MyNormals.^2,2)),1,3);

サインインしてコメントする。

その他の回答 (1 件)

Sai Charan Sampara
Sai Charan Sampara 2022 年 6 月 22 日
For a given set of points or vector , the plane that is passing through them is always unique. So if the points that are being plotted in the surface plot are correct then the plane that has been plotted is the one you are looking for. From what I can understand you have made a plane passing through the point mean_trajectory(2) and perpendicular to the vector mean_trajectory(1)-mean_trajectory(2).If you are expecting the plane to also pass through mean_trajectory(1), it will not happen. Hence the z value will not reach 3.3584e3. If you want the point to be in the middle of the plotted plane just change the values of x1,y1 such that the required point is inside that range.Try
ThemeCopy
x1 = linspace(120,130,10);
y1 = linspace(30,40,10);
If I misunderstood your question , clarify it a bit more regarding what exactly you are looking for.
  3 件のコメント
Sierra
Sierra 2022 年 6 月 22 日
I added one more image for clarification.
Sai Charan Sampara
Sai Charan Sampara 2022 年 6 月 23 日
After changing the limits on x1,y1 the surface seems to be perpendicular to the line joining the 2 trajectory points. I have attached a screen shot below.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by