# calculate the normal for a plane passing through more than three points

조회 수: 7 (최근 30일)
Alberto Acri . 2023년 9월 29일
편집: Matt J . 2023년 9월 30일
Hi! I have a plane passing through three points (triangular plane) and from which I determine the normal.
P = [ 0.034488 0.036484 0.006912; ...
0.019104 0.055041 0.047894; ...
-0.008596 0.123650 0.033786];
N = cross(P(1,:) - P(2,:), P(3,:) - P(2,:));
N = N/norm(N);
Is it possible to do the same thing with a circular plane ('V1_in')?
• If it is not possible to do this, how can I create the matrix equal to 'P' using the 'V1_in' plane?

댓글을 달려면 로그인하십시오.

### 채택된 답변

Bruno Luong 2023년 9월 29일
[~,~,V]=svd( V_1-mean(V_1));
N=V(:,3)
N = 3×1
0.2147 -0.1801 0.9599
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Bruno Luong 2023년 9월 29일
% Check againts other method for 3 points
P = [ 0.034488 0.036484 0.006912; ...
0.019104 0.055041 0.047894; ...
-0.008596 0.123650 0.033786];
N = cross(P(1,:) - P(2,:), P(3,:) - P(2,:));
N = N/norm(N)
N = 1×3
0.9037 0.3976 0.1592
[~,~,V]=svd( P-mean(P));
N=V(:,3)% opposite sign, which is arbitrary choice for a 2D plane
N = 3×1
-0.9037 -0.3976 -0.1592

댓글을 달려면 로그인하십시오.

### 추가 답변 (3개)

Torsten 2023년 9월 29일
편집: Torsten 님. 2023년 9월 29일
If the points in V1_in.mat all lie in a common plane, you can arbitrarily pick three points and define these points as P.
If the points are only "approximately" in a common plane, you have to determine this plane via regression (like @Bruno Luong did).
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

댓글을 달려면 로그인하십시오.

Matthew Blomquist 2023년 9월 29일
Hi Alberto,
If you think of the circular plane as a collection of points with coordinates (x, y, z), you can create a bunch of "triangular planes" by selecting any three coordinates to create a triangle. If all of the coordinates lie in the same plane, computing the normal of any triangular plane will be the same as computing the normal of the circular plane.
So, you can use the same code, but substitute three points from the circular plane (in V1_in) to your P matrix. Also, I often use the functions "patch" and "quiver3" to help visualize the normals.
Hope that helps!
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

댓글을 달려면 로그인하십시오.

Matt J 2023년 9월 30일
편집: Matt J 님. 2023년 9월 30일
Use planarFit() from this FEX package,
fitObj=planarFit(V_1')
fitObj =
planarFit with properties:
normal: [0.2147 -0.1801 0.9599]
distance: 82.5216
[hL,hD]=plot(fitObj); %Visualize the fit
legend([hL,hD],'Plane fit', 'XYZ samples', 'Location','northoutside','FontSize',15);
view(-70,15);drawnow

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by