How to plot a vector and line normal to vector

3 visualizzazioni (ultimi 30 giorni)
Hi all,
I get the following results from a code:
Grain 2 dom. wall normal to [0.525 0.927 0.930 ], seen as lines || to: [0.870 -0.492 ]
Grain 2 dom. wall normal to [0.538 -1.065 0.759 ], seen as lines || to: [-0.893 -0.451 ]
My question is, how do you plot a vector, and how do you plot the line parallel to the normal of the vector? I have tried a couple of methods but can never seem to get it working properly.
Thanks in advance for any responses,
Tamsin

Risposta accettata

Bjorn Gustavsson
Bjorn Gustavsson il 16 Apr 2020
If you have a normal-vector to a plane and want to plot 2 vectors in the plane you could do something like this:
n = [n_x,n_y,n_z]; % your normal-vector;
e_r = randn(1,3);e_r = e_r/norm(e_r); % randomly selected unit-vector;
% You should put in some checks for e_r being || to n here...
e1 = cross(n,e_r);
e1 = e1/norm(e1);
e2 = cross(n,e1);% and normalize
Then you have 2 perpendicular vectors in the plane. Plot with any of the arrow-functions you find on the file-exchange, I alternate between arrow3 and arrow
HTH

Più risposte (0)

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by