How to find the normal vector at a point on a curve in MatLab
16,342
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!
Related videos on Youtube
Author by
Sagar
Updated on June 04, 2022Comments
-
Sagar almost 2 years
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.
-
Schorsch almost 11 yearsAren't these tangential vectors and not normal vectors?
-
Shaun314 almost 11 yearsMy thoughts exactly Schorsch
-
Sagar almost 11 yearsThanks for your suggestion but for any1 that would be the first option to try. Nevertheless, it is not what I want. anyways thanks!
-
Shaun314 almost 11 yearsYeah, it looks like the other answer was really good, and I know there are a lot of FEX entries as well which I think calculate it for 2-d and 3-d curves so those might be worth checking out as well, best of luck!