[vtkusers] Angle between two vectors
David Cole
dlrdave at aol.com
Mon Jan 6 11:28:15 EST 2014
Knowledge and advice like this should be incorporated into a bonafide
method that's available to call in vtkMath (or let me know if there's a
better place for it).
Especially given that the most highly ranked Google results for
"compute angle between two vectors" predominantly advise to use
acos(dot)... There is mention of 3 techniques if you dig through enough
links, but it certainly seems like this sort of advice would be ranked
more highly.
I guess it comes down to how fast you need the method to be, and how
much "error" you can tolerate. The acos(dot) technique requires fewer
math ops, and therefore should be faster, but you might not get what
you want from all inputs. (It's been working fine for me, and I am
tracking an angle that goes to 0.... but apparently, YMMV.) The atan2
technique requires more math, but gives "better results"... Arguably in
most situations the speed difference may not even be noticeable. You'd
have to be doing lots of angle computations inside tight loops to
notice it probably.
So..... if I submit a gerrit patch to add this, using the atan2
technique, should it be named "double
vtkMath::AngleBetweenTwoVectors(double *v1, double *v2)"? Or is there
an better name for it (to follow other method names already existing in
vtkMath)....?
Thanks,
David C.
More information about the vtkusers
mailing list