# Compute angle between two vectors

5 messages
Open this post in threaded view
|
Report Content as Inappropriate

## Compute angle between two vectors

 Hi, I'm using  the epek kernel (without sqrt). I'm having two Vector_3 and want to compute the angle between them. I would usually compute the dot product between the normalized vectors, but I cannot compute the normalized vectors without sqrt. Is there also an (exact) way to compute the angle between the two vectors in CGAL? Thomas -- ==================================================== Dipl.-Ing. Thomas Holzmann TU Graz - Institut fuer Maschinelles Sehen und Darstellen Graz University of Technology - Institute for Computer Graphics & Vision Inffeldgasse 16/II, 8010 Graz, Austria http://www.icg.tugraz.at/phone: +43 316 873 5091 ==================================================== -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Compute angle between two vectors

 Le Friday, March 3, 2017 11:30:48 AM CET Thomas Holzmann a écrit : > Hi, > > I'm using  the epek kernel (without sqrt). > > I'm having two Vector_3 and want to compute the angle between them. > > I would usually compute the dot product between the normalized vectors, > but I cannot compute the normalized vectors without sqrt. > > Is there also an (exact) way to compute the angle between the two > vectors in CGAL? There is no way to compute exact angles. As far as I know, the acos, asin, atan, atan2 trigonometric functions are always using floating point numbers. Even if you only want to compute the cosine or the sinus of the angle, then you need the exact sqrt function. However, if you only want to compare two angles, or compare an angle with a constant (actually it will compare cosines and sinuses), then you can do it exactly without sqrt. -- Laurent Rineau, PhD R&D Engineer at GeometryFactory           http://www.geometryfactory.com/Release Manager of the CGAL Project       http://www.cgal.org/-- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Compute angle between two vectors

 On 03/03/2017 12:50 PM, Laurent Rineau (CGAL/GeometryFactory) wrote: > Le Friday, March 3, 2017 11:30:48 AM CET Thomas Holzmann a écrit : >> Hi, >> >> I'm using  the epek kernel (without sqrt). >> >> I'm having two Vector_3 and want to compute the angle between them. >> >> I would usually compute the dot product between the normalized vectors, >> but I cannot compute the normalized vectors without sqrt. >> >> Is there also an (exact) way to compute the angle between the two >> vectors in CGAL? > There is no way to compute exact angles. As far as I know, the acos, asin, > atan, atan2 trigonometric functions are always using floating point numbers. > Ok, thanks for the answer. Is there a way to normalize exact vectors (without sqrt). When I could compute an exact unit vector, the inexact angle computation would not be a problem... Thomas -- ==================================================== Dipl.-Ing. Thomas Holzmann TU Graz - Institut fuer Maschinelles Sehen und Darstellen Graz University of Technology - Institute for Computer Graphics & Vision Inffeldgasse 16/II, 8010 Graz, Austria http://www.icg.tugraz.at/phone: +43 316 873 5091 ==================================================== -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Compute angle between two vectors

 Le Friday, March 3, 2017 1:32:41 PM CET Thomas Holzmann a écrit : > Is there a way to normalize exact vectors (without sqrt). When I could > compute an exact unit vector, the inexact angle computation would not be > a problem... I do not think so. Let's take for example the vector {1., 1., 1.}. Its normalize version is:   { 1./sqrt(3.), 1./sqrt(3.), 1./sqrt(3.) } I think you cannot normalize vectors without being able to compute sqrt. You can probably compute *approximately normalized* vectors, though. -- Laurent Rineau, PhD R&D Engineer at GeometryFactory           http://www.geometryfactory.com/Release Manager of the CGAL Project       http://www.cgal.org/-- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss