Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angle between two vectors matlab

I want to calculate the angle between 2 vectors V = [Vx Vy Vz] and B = [Bx By Bz]. is this formula correct?

VdotB = (Vx*Bx + Vy*By + Vz*Bz)

 Angle = acosd (VdotB / norm(V)*norm(B))

and is there any other way to calculate it?

My question is not for normalizing the vectors or make it easier. I am asking about how to get the angle between this two vectors

like image 210
Jack_111 Avatar asked Aug 20 '13 08:08

Jack_111


People also ask

How do you calculate an angle in Matlab?

angle takes a complex number z = x + iy and uses the atan2 function to compute the angle between the positive x-axis and a ray from the origin to the point (x,y) in the xy-plane.


1 Answers

Based on this link, this seems to be the most stable solution:

atan2(norm(cross(a,b)), dot(a,b))
like image 115
Dennis Jaheruddin Avatar answered Sep 23 '22 15:09

Dennis Jaheruddin