creation of a circular plane passing through three nodes and for central node

2 visualizzazioni (ultimi 30 giorni)
Hi. I would like to generate a circular plane from three nodes + center nodes.
I'm using this code but I don't understand why a plane is generated that doesn't go through those three nodes (it only goes through the center node).
A = [28.9646 -21.3886 97.3614
23.1935 -19.9821 97.2254
27.9585 -16.222 95.2403];
A_mean = mean(A);
R = 5;
t = (0:359)';
a_A = A(1);
b_A = A(2);
c_A = A(3);
plane = R*[cosd(t),sind(t)]*null([a_A,b_A,c_A])' + A_mean(:)';
figure
plot3(A(:,1),A(:,2),A(:,3),'r.','Markersize',27);
hold on
plot3(A_mean(:,1),A_mean(:,2),A_mean(:,3),'r.','Markersize',27);
patch(plane(:,1),plane(:,2),plane(:,3),'k.');
hold off
axis equal

Risposta accettata

John D'Errico
John D'Errico il 9 Ott 2023
Modificato: John D'Errico il 9 Ott 2023
It does not pass through those other points, because ... your code is wrong. Seems simple enough. What did you do incorrectly?
  1. You did not index into A properly. I think you do not understand matrices, and how to index into them.
  2. You did not use null properly, partly because you failed to correctly index into A, but also because you do not understand null, and what it does.
The rest of your code seems fine though. ;-)
A = [28.9646 -21.3886 97.3614
23.1935 -19.9821 97.2254
27.9585 -16.222 95.2403];
A_mean = mean(A);
R = 5;
t = (0:359)';
No problems so far. You want to create a circle of radius 5, and you generate a set of points in DEGREES to go around the circle. That is fine, as long as you use degree trig functions, which you do. Better to learn what radians are in the future, but nothing to complain about.
a_A = A(1);
b_A = A(2);
c_A = A(3);
WRONG. WRONG. WRONG.
That is not how you extract vectors as rows of A. Flat out wrong. Instead, you may have wanted to write this:
a_A = A(1,:);
b_A = A(2,:);
c_A = A(3,:);
But that is irrelevant, since what you really wanted to do was to subtract off one of those vectors from the other two, and apply orth to that result. That will give you a pair of vectors that form a basis for the planar subspace parallel to the plane the circle lies in. Then you add back the mean to that later on, translating that plane.
plane = R*[cosd(t),sind(t)]*orth((A(2:3,:) - A(1,:))')' + A_mean;
Now we can go back to your code.
figure
plot3(A(:,1),A(:,2),A(:,3),'r.','Markersize',27);
hold on
plot3(A_mean(:,1),A_mean(:,2),A_mean(:,3),'r.','Markersize',27);
patch(plane(:,1),plane(:,2),plane(:,3),'k.');
hold off
axis equal
Oh. By the way, you did not need to do this:
A_mean(:)'
A_mean is already a row vector. A_mean(:) turns it into a column vector. Then the transpose just makes it back into a row vector. So I took the : and the transpose out.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by