This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Angle calculation

Tags: None
(comma "," separated)
hanckmann
Registered Member
Posts
1
Karma
0
OS

Angle calculation

Thu Mar 11, 2010 3:19 pm
When there are two vectors (Eigen::Vector3d v1, v2;), is there a function that can return the angle between the vectors?

I have searched for a function on the Eigen website, but did not find it. However, I figured that this was probably a trivial function that is implemented.

If there is a function like this, where can I find it/how can I use it. If not, would it be interesting to implement it and send it in as a patch?

t.a.f.
Patrick
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: Angle calculation

Thu Mar 11, 2010 4:55 pm
We don't have such a function. But it would be just a matter of doing:

atan2(a.dot(b), a.cross(b).norm());

I'm not really decided if we want to have that in Eigen... the above formula is the right one in general, but in special cases users may prefer to use their own formulas that may be faster... for example if the angle is known not to be too close to 0 or a half turn, of if precision at these angles doesn't matter too much, and if the vectors are normalized, then the formula arccos(a.dot(b)) will be faster...


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]