I understand that the goal is to compute the the X and Y components of the normal vector to a given curve. This can be achieved by following the steps given below:
- Parameterize the curve as ( (x(t), y(t)) ) or as discrete points ((x_i, y_i)).
- Compute the tangent vector at each point.
- Find the normal vector by rotating the tangent vector by 90°.
Here is an exmaple script you may refer to implement the above steps:
x = linspace(-2, 2, 100);
norms = sqrt(dy_dx.^2 + 1);
plot(x, y, 'b-', 'LineWidth', 2); hold on;
quiver(x, y, nx, ny, 0.3, 'r');
title('Parabola with normal vectors');
legend('Curve', 'Normals');
Here is an image of the resulting plot:
I hope this helps!