[vtkusers] Angle between two vectors

David Gobbi david.gobbi at gmail.com
Fri Apr 15 11:10:39 EDT 2016


Hi Laurent,

The differences between acos() and atan2() are on the order of 1e-10,
so they cannot explain the huge differences that you are seeing in
your results.  You almost definitely made a mistake in your code, e.g.
forgetting to normalize a vector.

 - David


On Fri, Apr 15, 2016 at 8:25 AM, Laurent <l.paul at uclouvain.be> wrote:

> Dear users,
>
> Sorry to dig up this post, but I'm troubled by the results I get.
> I used to use the acos() method until I found out that the resulting values
> were poor.
> We fixed it using the atan2 method instead. Seems working much better!
>
> David (Gobbi), could you elaborate a bit on the error when the angle
> approaches 0?
> I mean, I get huge differences between both methods. As an example, I get
> atan2 Vs acos (in degres):
> - 3.67 Vs 10.08
> - 11.03 Vs 15.82
> - 3.24 Vs 20.02
> - 7.78 Vs 20.05
> - ...
>
> How to explain these differences?
> I've checked if clamp values would give better results but the dot produces
> values between -1 and +1.
> I've checked multiple times if there was no mistake, and there's not.
> I'm horrified!
>
> Since I use the python/numpy distribution from paraview 4.1,
> AngleBetweenVectors in not implmented and I had to reimplement the
> calculation; That's why I jumped into it more deeply.
>
> Thanks,
> Laurent.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160415/30bfc372/attachment.html>


More information about the vtkusers mailing list