plotting normal vector in 3d

此生再无相见时 提交于 2021-02-18 17:04:25

问题


I have a normal vector that I calculated from the cross product of two vectors [xn,yn,zn] and I have a point[x0,y0,z0] how can I plot the normal in 3d. I didn't know how to do it. Any suggestions please?


回答1:


With Arrow heads:

a = [2 3 5]; % your point [x0,y0,z0]
b = [1 1 0]; % your normal vector 
c = a+b; % end position of normal vector

%quiver3 syntax: quiver3(x,y,z,u,v,w)
quiver3(a(1), a(2), a(3), c(1), c(2), c(3));
axis equal;

This will hopefully draw a vector from your point into the direction of your normal...with arrow heads. If you want to draw a simple line in 3D you must use plot3:

plot3(X1,Y1,Z1,...)

The function call should be the same as for quiver3. :)

EDIT/ADD: I just saw that I might have misunderstood what quiver3 does. Actually it seems, that you don't need to substract or add b from a. Because quiver3 just adds a given vector (u, v, w) to a point (x, y, z). Without checking it, I think the call should look like:

a = [2 3 5]; % your point [x0,y0,z0]
b = [1 1 0]; % your normal vector 
quiver3(a(1), a(2), a(3), b(1), b(2), b(3));


来源:https://stackoverflow.com/questions/17940766/plotting-normal-vector-in-3d

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!