How to plot a vector and line normal to vector

3 次查看(过去 30 天)
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

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2020-4-16
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 个)

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by