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

青春壹個敷衍的年華 提交于 2019-12-22 09:48:04

问题


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.

Please guide me how can I achieve this in MatLab.

Thanks in advance.


回答1:


Using the explanation from this incredible SO question:

if we define dx=x2-x1 and dy=y2-y1, then the normals are (-dy, dx) and (dy, -dx).

Here's an example using an analytic curve of 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!!! Got in a hurry. Thanks to Schorsch and Shawn314!




回答2:


I hate to say it, but going back to Calculus 1 might be a pretty viable option here. 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



来源:https://stackoverflow.com/questions/17324936/how-to-find-the-normal-vector-at-a-point-on-a-curve-in-matlab

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