0
votes

I am trying to determine if the movement of two objects is "in phase" or opposing each other. So basically I have two vectors, R1, R2 in R^3 and I want to know if they "point in the same direction".

I can think of two ways to compute that: a) Calculate the angle between the two vectors. The angle indicates their alignment. b) Calculate the correlation coefficient between the two vectors. (e.g. using Matlab's corr function) 1 means they are parallel, -1 antiparallel. If they are perpendicular I do get either plus or minus 0.5, which seems wrong.

Is there a difference in using the two methodologies? My gut feeling says that the two methods should be identical, but I am not sure. Anyone has some insights and what could be potential differences/advantages of the methods? Thanks!

1
The correlation is related to the cosine of the angle, for details see this. - rozsasarpi

1 Answers

1
votes

This is most easily done by calculating the dot product between the two normalized vectors. The inverse cosine gives directly the angle between the vectors.

Matlab doesn't have a "corr" function. It has "xcorr". The cross correlation between two 3 element vectors is a 5 element vector. The middle element of that is the same as the dot product, so it's basically the same calculation.