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:
Check for angle = 0 between vectors

Subject: Check for angle = 0 between vectors

From: Els

Date: 21 May, 2010 07:27:05

Message: 1 of 7

I have possibly a very simple question.

I have a vector a(x,y,z)(between P and P1), and a vector b(x1,y1,z1)(between P1 and P2).

How do I check in Matlab that the two vectors are in line with each other? So that the angle between the vectors is zero.

Subject: Check for angle = 0 between vectors

From: Yi Cao

Date: 21 May, 2010 07:45:21

Message: 2 of 7

"Els " <y.e.t.reeuwijk@student.utwente.nl> wrote in message <ht5ck9$4up$1@fred.mathworks.com>...
> I have possibly a very simple question.
>
> I have a vector a(x,y,z)(between P and P1), and a vector b(x1,y1,z1)(between P1 and P2).
>
> How do I check in Matlab that the two vectors are in line with each other? So that the angle between the vectors is zero.

You can check the difference between a'*b and norm(a)*norm(b), whether it is zero.

HTH
Yi

Subject: Check for angle = 0 between vectors

From: Els

Date: 21 May, 2010 08:41:15

Message: 3 of 7

a and b are both row vectors, so

A=a'*b
B=norm(a)*norm(b)

gives me a problem, because A is a 3x3 matrix.
Is it correct to say that A=a*b'?

And that the difference G = round(abs(A-B))?

Subject: Check for angle = 0 between vectors

From: Hiram K. Hackenbacker

Date: 21 May, 2010 12:38:17

Message: 4 of 7

"Els " <y.e.t.reeuwijk@student.utwente.nl> wrote in
news:ht5ck9$4up$1@fred.mathworks.com:

> I have possibly a very simple question.
>
> I have a vector a(x,y,z)(between P and P1), and a vector
> b(x1,y1,z1)(between P1 and P2).
>
> How do I check in Matlab that the two vectors are in line with each
> other? So that the angle between the vectors is zero.

Check the vector cross product = [0 0 0]
C = cross(A,B); A, B Vectors

Subject: Check for angle = 0 between vectors

From: Yi Cao

Date: 21 May, 2010 13:20:05

Message: 5 of 7

"Els " <y.e.t.reeuwijk@student.utwente.nl> wrote in message <ht5gvb$l08$1@fred.mathworks.com>...
> a and b are both row vectors, so
>
> A=a'*b
> B=norm(a)*norm(b)
>
> gives me a problem, because A is a 3x3 matrix.
> Is it correct to say that A=a*b'?
>
> And that the difference G = round(abs(A-B))?

That is right.

Yi

Subject: Check for angle = 0 between vectors

From: David Young

Date: 21 May, 2010 14:25:04

Message: 6 of 7

"Hiram K. Hackenbacker" <brains@ir.org> wrote in message <Xns9D7FE129A4906brainsirorg@61.9.191.5>...
> "Els " <y.e.t.reeuwijk@student.utwente.nl> wrote in
> news:ht5ck9$4up$1@fred.mathworks.com:
>
> > I have possibly a very simple question.
> >
> > I have a vector a(x,y,z)(between P and P1), and a vector
> > b(x1,y1,z1)(between P1 and P2).
> >
> > How do I check in Matlab that the two vectors are in line with each
> > other? So that the angle between the vectors is zero.
>
> Check the vector cross product = [0 0 0]
> C = cross(A,B); A, B Vectors

No, the cross product is zero for vectors that are orthogonal to each other.

Subject: Check for angle = 0 between vectors

From: David Young

Date: 21 May, 2010 14:27:20

Message: 7 of 7

Sorry - my mistake - not thinking - ignore my previous message. Yes, the cross product is correct.

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