how to plot a plane using equations of planes?
3 views (last 30 days)
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);
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
Karim on 22 Jun 2022
Edited: Karim on 22 Jun 2022
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
scatter3(XYZ(:,1), XYZ(:,2), XYZ(:,3),'r','filled')
% 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
More Answers (1)
Sai Charan Sampara on 22 Jun 2022
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
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.