[vtkusers] Angle between two vectors

David Cole dlrdave at aol.com
Mon Jan 6 15:20:00 EST 2014


> Interesting discussion!
>
> We have a little angle function as described here and it uses acos(). 
 I've
> changed it to use atan2 and the results are equal (in my typical 
usage) to at
> least 1e-12.
>
> I measured performance too.  On my Mac Pro, in debug, averaged after 
1000 runs,
> the atan2 version is actually faster at 2.7 µs vs 3.7 µs for the acos 
version.
> In release it's the opposite, with acos at 70 ns and atan2 at 379 ns. 
 I didn't
> look too closely; I'd say it's a wash.

Thanks for trying it out and doing some testing....

My advice is: never use a debug build for performance measurements. As 
you can see by comparing debug to release, there's so much "debug-ness" 
in a Debug build that it basically swamps your actual code with 
debug-library-related overhead time. It's literally orders (plural) of 
magnitude.

If I was to make a decision based on a 5x difference in speed, I would 
definitely go with the faster one. But, since a single call takes way 
less than a microsecond, I would only need to consider this if I was 
calling it millions of times.

Thanks for the data


D



More information about the vtkusers mailing list