Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
HELP: Vector normal to curve in every point

Subject: HELP: Vector normal to curve in every point

From: Suzana

Date: 24 Nov, 2011 11:27:09

Message: 1 of 4

Dear,

I'm working on human gait analysis, and I have to work with motion curves in MatLab. And I have to say that I'm new in MatLab.

My problem is related to defining normal vectors of two 2d curve, and plot that vectors in evry point on the curves. After that, I have to define angle between corespondent normal vectors. I'm creating curve from set of x and y points (e.i. from MS Excel file).
I tried to define normal vectors and angles between them , but I'm not sure that I'm doing the right thing.

%reading.xls files
a = xlsread('Marker femur-koleno_IP_24.05.P.xls');
b = xlsread('Marker tibia-koleno_IP_24.05.P.xls');

%definingu x & y coordinates in file a
x1 = a(:,1);
y1 = a(:,2);

%definingu x & y coordinates in file b
x2 = b(:,1);
y2 = b(:,2);

%Number of rows
i1=219;

%Unit normal vector
n=[1 1]

%Curves plotting
plot(x1,y1,'r',x2,y2,'b')

hold on

%Defining points (r0 & r0tt) on the curves in which I have to plot the normal vector of % curve
% k & p defining points and normal vectors on them
%ang defining angle between normal vectors of curves in corespondent points
for i=1:i1
      r0=[x1(i) y1(i)];
      r0tt=[x2(i) y2(i)];
      k=quiver(r0(1), r0(2), n(1), n(2));
      p=quiver(r0tt(1), r0tt(2), n(1), n(2));
      ang(i) = (180/pi)*(atan2(abs(r0(1)*n(2)-n(1)*r0tt(2)),r0(1)*r0tt(1)+n(1)*n(2)));
end

hold off

I hope so that you'll help me because I have no more ideas.

Best regards,
Suzana

Subject: HELP: Vector normal to curve in every point

From: Rune Allnor

Date: 24 Nov, 2011 13:07:58

Message: 2 of 4

On 24 Nov, 12:27, "Suzana " <suzana.petro...@mfkg.rs> wrote:
> Dear,
>
> I'm working on human gait analysis, and I have to work with motion curves in MatLab. And I have to say that I'm new in MatLab.
>
> My problem is related to defining normal vectors of two 2d curve, and plot that vectors in evry point on the curves. After that, I have to define angle between corespondent normal vectors. I'm creating curve from set of x and y points (e.i. from MS Excel file).
> I tried to define normal vectors and angles between them , but I'm not sure that I'm doing the right thing.

The problem is ill defined: Consider a curve consisting
of three points, e.g. (0,0), (1,1), (2,0).

What vector would be normal to this curve in the point (1,2)?

One can not help with your problem until this
question has been answered. Or you at least have
decided how to treat that particulal point.

Rune

Subject: HELP: Vector normal to curve in every point

From: Suzana

Date: 24 Nov, 2011 13:28:08

Message: 3 of 4

Dear Rune Allnor,

I have coordinates of points in MS Excel which I use for calculating parameters that I need. In that points I have to define normal vector to curve. Because of that reason, I tried to define for loop to determine points in which I want to draw normal to curve.
I do not need to define new points outside my MS Excel files.

Best regards
Suzana

Subject: HELP: Vector normal to curve in every point

From: Roger Stafford

Date: 24 Nov, 2011 19:00:09

Message: 4 of 4

"Suzana" wrote in message <jal9md$eoh$1@newscl01ah.mathworks.com>...
> n=[1 1]
- - - - - - - -
  The assignment n = [1,1] wouldn't in general be correct. It should be orthogonal to the curve at each point which means that it is a variable quantity which depends on the slope of a tangent to the curve. (Also your n isn't a unit vector - it has magnitude sqrt(2).)

  You can use matlab's 'gradient' function to approximate the normal direction. First obtain for each point the gradient, m, which is an approximation for the derivative, dy/dx, at that point. Then rotating counterclockwise by ninety degrees to get the normal would give:

 n = [-m,1]/sqrt(m^2+1);

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us