Compute angle between two vectors

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Compute angle between two vectors

tholzmann
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


Reply | Threaded
Open this post in threaded view
|

Re: Compute angle between two vectors

Laurent Rineau (CGAL/GeometryFactory)
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


Reply | Threaded
Open this post in threaded view
|

Re: Compute angle between two vectors

tholzmann


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


Reply | Threaded
Open this post in threaded view
|

Re: Compute angle between two vectors

Laurent Rineau (CGAL/GeometryFactory)
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


Reply | Threaded
Open this post in threaded view
|

Re: Compute angle between two vectors

tholzmann


On 03/03/2017 03:07 PM, Laurent Rineau (CGAL/GeometryFactory) wrote:

> 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.
>
Yes, I'm already doing that. I just thought maybe there is a more
elegant way to do this...

Thanks!

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