How to plot a vector and line normal to vector
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tamsin O'Reilly
le 16 Avr 2020
Réponse apportée : Bjorn Gustavsson
le 16 Avr 2020
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
0 commentaires
Réponse acceptée
Bjorn Gustavsson
le 16 Avr 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
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!