如何计算从 3d 矩阵中的所有点到 matlab 中的平面的距离?
How to calculate the distance from all points in a 3d matrix to a plane in matlab?
此问题来自、
但我会只关注一个特定的部分,
如果我有一个 3d 矩阵 M,256*256*124,以及一个由与 3d 矩阵相交的 3 个点定义的平面,A,B ,C,如何求M中所有点到A,B,C定义的平面的距离
这是我得到的建议,
[X Y Z] = meshgrid(1:256,1:256,1:124)
A = [X(:)';Y(:)';Z(:)'];
n = cross([coor_A-coor_B],[coor_B-coor_C]); %The norm vector of the plane
d = norm(mean([coor_A,coor_B,coor_C]),2); %The distance from origin to the plane
L = ((n*A)-d); %The distance from all points in M to the plane
但是L中的值都很大,说明在交平面上找不到点。
谁能告诉我怎么了?
您在维基百科页面上漏掉了一行
哪里
所以添加这一行
n0 = n / norm(n);
并将最后一行更改为
L = ((n0*A)-d);
此问题来自
但我会只关注一个特定的部分,
如果我有一个 3d 矩阵 M,256*256*124,以及一个由与 3d 矩阵相交的 3 个点定义的平面,A,B ,C,如何求M中所有点到A,B,C定义的平面的距离
这是我得到的建议,
[X Y Z] = meshgrid(1:256,1:256,1:124)
A = [X(:)';Y(:)';Z(:)'];
n = cross([coor_A-coor_B],[coor_B-coor_C]); %The norm vector of the plane
d = norm(mean([coor_A,coor_B,coor_C]),2); %The distance from origin to the plane
L = ((n*A)-d); %The distance from all points in M to the plane
但是L中的值都很大,说明在交平面上找不到点。
谁能告诉我怎么了?
您在维基百科页面上漏掉了一行
哪里
所以添加这一行
n0 = n / norm(n);
并将最后一行更改为
L = ((n0*A)-d);