简体   繁体   English

如何在MatLab中的曲线上找到法线向量

[英]How to find the normal vector at a point on a curve in MatLab

I have a curve and I want to find the normal vector at a given point on this curve, later I have to find the dot product of this normal vector with another vector. 我有一条曲线,我想在这条曲线上的给定点找到法线向量,后来我必须找到这个法线向量与另一个向量的点积。

I tried the gradient function of MatLab, but I guess it doesnt work when we need to find the gradient at a specific point still I am not sure if I am wrong. 我尝试了MatLab的渐变功能,但我想当我们需要在特定点找到渐变时它不起作用我还不确定我是不是错了。

Please guide me how can I achieve this in MatLab. 请指导我如何在MatLab中实现这一目标。

Thanks in advance. 提前致谢。

Using the explanation from this incredible SO question : 使用这个令人难以置信的SO问题的解释:

if we define dx=x2-x1 and dy=y2-y1, then the normals are (-dy, dx) and (dy, -dx). 如果我们定义dx = x2-x1和dy = y2-y1,则法线为(-dy,dx)和(dy,-dx)。

Here's an example using an analytic curve of y = x^2 这是一个使用y = x^2的解析曲线的例子

x = 0:0.1:1;
y = x.*x;
dy = gradient(y);
dx = gradient(x);
quiver(x,y,-dy,dx)
hold on; plot( x, y)

which gives: 这使:

颤动

PS: Sorry about the tangential example!!! PS:对不起切线的例子!!! Got in a hurry. 匆匆忙忙。 Thanks to Schorsch and Shawn314! 感谢Schorsch和Shawn314!

I hate to say it, but going back to Calculus 1 might be a pretty viable option here. 我不想这么说,但回到微积分1可能是一个非常可行的选择。 Calculate derivative of curve at your point, find normal to that, I think if you were to just google "Matlab deriviate" and "calculate normal to derivative" you should be good 计算你的点的曲线导数,找到正常的,我想如果你只是谷歌“Matlab派生”和“计算正常导数”你应该是好的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM