Distance from point to plane
16 次查看(过去 30 天)
显示 更早的评论
Hi everywhere!
A question; How can I compute the distance between a plane (in ellipsoidal coordinates) to a point (in ellipsoidal coordinates too)?
The plane have 4 points (the borders points), and I need calculate the closest distance from this plane to a point.
For example;
%Lon. %Lat. %Depth (km)
Plane= [-74.65180 -37.74230 1.62620
-72.86330 -33.14430 1.62620
-70.88940 -33.64880 62.19350
-72.67800 -38.24670 62.19350
-74.65180 -37.74230 1.62620]
Point=[-72.7060 -37.7950]
Thank you so much!
0 个评论
回答(3 个)
Matt J
2014-12-7
编辑:Matt J
2014-12-7
Well, the fact that you have ellipsoidal coordinates shouldn't matter, because you can convert them to Cartesian coordinates PlaneCart and PointCart. Once you've done so
c=mean(PlaneCart);
N=null(bsxfun(@minus, PlaneCart,c));
N=mean(N,2);
distance=abs(dot(N,c-PointCart));
6 个评论
Matt J
2014-12-9
Let's do this together with the following sample data
PlaneCart=eye(3); PointCart=[0,0,0];
When I run with the above inputs, I obtain
distance =
0.5774
Do you not obtain the same thing? And do you disagree that this is the correct distance from the origin to the plane containing the rows of eye(3)? If you disagree, then you have given us the wrong description of your problem in some way.
Thorsten
2014-12-8
This is a math question rather than a Matlab question. First convert your plane from 3-point-form to Hessian normal form http://mathworld.wolfram.com/Plane.html. Second compute the point-plane distance http://mathworld.wolfram.com/HessianNormalForm.html
Thorsten
2014-12-15
Plane= [-37.7423 -74.6518 1.6262
-33.1443 -72.8633 1.6262
-33.6488 -70.8894 62.1935
-38.2467 -72.6780 62.1935];
Point=[ -33.3210 -71.4110];
for i=1:4
[x(i),y(i),z(i)]=ell2xyz(deg2rad(Plane(i,1)),deg2rad(Plane(i,2)),-Plane(i,3)*1000);
end
P1=[x(1),y(1),z(1)]/1000; %en km
P2=[x(2),y(2),z(2)]/1000; %en km
P3=[x(3),y(3),z(3)]/1000; %en km
P4=[x(4) y(4) z(4)]/1000;
n = cross(P1-P2, P1-P3);
d = dot(-P1, n)
nnorm = n/norm(n);
p = d/norm(n);
Distance = dot(nnorm, P4) + p
Distance =
2.8967
That means that Point 4 is not in the plane, but has a distance of 2.89 km.
[xPo,yPo,zPo]=ell2xyz(deg2rad(Point(1)),deg2rad(Point(2)),0);
Po = [xPo yPo zPo];
Distance = dot(nnorm, Po) + p
Distance =
-6.0717e+006
So point Po lies 6.07 km low the plane. Does this make sense?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!