Find center of a plane and project center point perpendicular to plane

13 visualizzazioni (ultimi 30 giorni)
For instance, lets say I have 4 data points (each with XYZ coordinates). I want to make a 3 dimensional planar surface out of these set of points and find the center of this plane. Then, subsequently be able to project this center perpendicular to the plane by a variable distance.
Any suggestions?
  1 Commento
Walter Roberson
Walter Roberson il 31 Lug 2019
Center of the plane is just the centroid of the points.
But you have problems if the points are not coplanar.

Accedi per commentare.

Risposta accettata

Fabio Freschi
Fabio Freschi il 31 Lug 2019
As already pointed out by Walter Roberson, 4 points cannot be coplanar. Assuming that they are, you may try this
clear variables, close all
% three random points in 3d
P = rand(3,3);
% vectors
V1 = P(2,:)-P(1,:);
V2 = P(3,:)-P(1,:);
% add one point on the plane defined by the previous three points
P = [P; P(1,:)+V1+V2];
% plot points
figure, hold on, axis equal
plot3(P(:,1),P(:,2),P(:,3),'o');
quiver3(P(1,1),P(1,2),P(1,3),V1(1),V1(2),V1(3),'AutoScale','off')
quiver3(P(1,1),P(1,2),P(1,3),V2(1),V2(2),V2(3),'AutoScale','off')
% plane center
B0 = mean(P,1);
% plot
plot3(B0(1),B0(2),B0(3),'*');
% orthogonal vector
W = cross(V2,V1);
% unit vector
U = W/sqrt(sum(W.^2,2));
% project B by the distance k
k = 2;
B = B0+k*U;
% plot
quiver3(B0(1),B0(2),B0(3),k*U(1),k*U(2),k*U(3),'AutoScale','off');
plot3(B(1),B(2),B(3),'s');
Basically two vectors are created from the first three points, assuming the first point as reference. The orthogonal direction is obtained with a cross product of these vectors. Note that you can control the positive side by changing the order of the cross product.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by