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:
angle between two vectors

Subject: angle between two vectors

From: shah baba

Date: 10 Jun, 2011 14:37:04

Message: 1 of 3

hi
I have a vector n1 of pt1[x1,y1,z1] from origin [0,0,0] and n2 of p2[x2,y2,z2]from origin [0,0,0].
The angle between n1 and n2
                            n1 . n2
        cos q = ---------------------
                         ||n1|| ||n2||
How can I decompose angle (q) it into its three components(alpha, beta gamma)
regards,

Subject: angle between two vectors

From: James Tursa

Date: 10 Jun, 2011 14:50:20

Message: 2 of 3

"shah baba" <shahbaba@gmx.de> wrote in message <ista6g$okq$1@newscl01ah.mathworks.com>...
> hi
> I have a vector n1 of pt1[x1,y1,z1] from origin [0,0,0] and n2 of p2[x2,y2,z2]from origin [0,0,0].
> The angle between n1 and n2
> n1 . n2
> cos q = ---------------------
> ||n1|| ||n2||
> How can I decompose angle (q) it into its three components(alpha, beta gamma)
> regards,

Please define alpha, beta, and gamma. Are they some type of Euler Angle sequence? Or what?

Also, using the above formula is not the most robust way of getting the angle. There are several old newsgroup discussions of this, but it basically boils down to using both sin (with a cross product) and cos (with a dot product as you have used) and then feeding that to the atan2 function to get the angle.

James Tursa

Subject: angle between two vectors

From: Roger Stafford

Date: 10 Jun, 2011 14:53:06

Message: 3 of 3

"shah baba" <shahbaba@gmx.de> wrote in message <ista6g$okq$1@newscl01ah.mathworks.com>...
> hi
> I have a vector n1 of pt1[x1,y1,z1] from origin [0,0,0] and n2 of p2[x2,y2,z2]from origin [0,0,0].
> The angle between n1 and n2
> n1 . n2
> cos q = ---------------------
> ||n1|| ||n2||
> How can I decompose angle (q) it into its three components(alpha, beta gamma)
> regards,
- - - - - - - - -
  The formula

 q = atan2(norm(cross(n1,n2)),dot(n1,n2))

is more robust for finding q. The arc cosine becomes inaccurate for angles near 0 or pi.

  As for your question, what three components are you referring to? Alpha, beta, and gamma could refer to anything.

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