Got Questions? Get Answers.
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:
Vectors

Subject: Vectors

From: M K

Date: 12 Nov, 2008 12:56:02

Message: 1 of 6

I have 4 points of a plane, ABCD .Can i calculate the normal vector,n of it?

Is it n= cross(AB,CD)?

Subject: Vectors

From: M K

Date: 12 Nov, 2008 13:10:04

Message: 2 of 6

Can the Dot product of two vectors, A and B in Matlab be written as

dot(A,B)/norm(A)*norm(B)=cos(teta)




"M K"

<maha_k@mathworks.com> wrote in message <gfejp2$od9$1@fred.mathworks.com>...
> I have 4 points of a plane, ABCD .Can i calculate the normal vector,n of it?
>
> Is it n= cross(AB,CD)?

Subject: Vectors

From: M K

Date: 12 Nov, 2008 13:23:02

Message: 3 of 6

Sorry I should re-phrase that.

Calculating the aangle between two vectors. I did a search on this forum and found another thread which gave two ways of calculating it

1) the usual acos(dot(A,B)/(norm(A)*norm(B))

2) angle = atan2(norm(cross(a,b)),dot(a,b));

I get different answers when I use these two ... Any help will be appreciated!

Subject: Vectors

From: John D'Errico

Date: 12 Nov, 2008 13:28:01

Message: 4 of 6

"M K" <maha_k@mathworks.com> wrote in message <gfejp2$od9$1@fred.mathworks.com>...
> I have 4 points of a plane, ABCD .Can i calculate the normal vector,n of it?
>
> Is it n= cross(AB,CD)?

Are these 4 points that lie in a plane in how many
dimensions?

In 3-d, only 3 points determine a plane. Are all 4
points known to lie in the same plane? (If they are
not coplanar, then you cannot determine a normal
vector.)

So what do you have? Perhaps the simplest solution
to your question is to use null. Assuming that A,B,C,D
are all row vectors, then do this:

N = null([B-A;C-A;D-A]);

John

Subject: Vectors

From: John D'Errico

Date: 12 Nov, 2008 13:31:49

Message: 5 of 6

"M K" <maha_k@mathworks.com> wrote in message <gfekjc$46l$1@fred.mathworks.com>...
> Can the Dot product of two vectors, A and B in Matlab be written as
>
> dot(A,B)/norm(A)*norm(B)=cos(teta)
>

First of all, if you have a new question, put it in a
new thread!

What is your question anyway?

The dot product of two vectors is just

  dot(A,B)

or if A and B are row vectors, then just

  A*B'

Are you trying to compute the cosine of the
angle between the vectors? Why not say it?

John

Subject: Vectors

From: Roger Stafford

Date: 12 Nov, 2008 18:02:01

Message: 6 of 6

"M K" <maha_k@mathworks.com> wrote in message <gfelbm$cc9$1@fred.mathworks.com>...
> Sorry I should re-phrase that.
>
> Calculating the aangle between two vectors. I did a search on this forum and found another thread which gave two ways of calculating it
>
> 1) the usual acos(dot(A,B)/(norm(A)*norm(B))
>
> 2) angle = atan2(norm(cross(a,b)),dot(a,b));
>
> I get different answers when I use these two ... Any help will be appreciated!
-----------
  I assume that you are dealing with three-element vectors in three-dimensional space, with the angle between vectors being regarded as lying somewhere between 0 and pi. In theory the two formulas you mention should give exactly the same answers. However, in terms of computational robustness the first formula suffers a loss of accuracy for angles that lie very near either 0 or pi. The derivative of the 'acos' function approaches infinity at such values and this results in excessive computational errors. The 'atan2' function avoids this difficulty for all angles in the range. That might account for the differences you allude to.

  It would help if you could give a concrete example of the a and b vector values and the differences you are seeing between the two formulas' results.

Roger Stafford

Tags for this Thread

No tags are associated with 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