comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Calculate the included angle between two vectors
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Calculate the included angle between two vectors [message #65971] Fri, 10 April 2009 02:47
jameskuyper is currently offline  jameskuyper
Messages: 79
Registered: October 2007
Member
Chris wrote:
> On Apr 9, 5:43 am, Pierre <pierre.villene...@gmail.com> wrote:
>> On Apr 9, 7:14 am, "dux...@gmail.com" <dux...@gmail.com> wrote:
>>
>>> Is there a function which can calculate the included angle between
>>> two three-dimensional vectors?
>>> jdu
>> Here's a simple solution. Assume v1 and V2 are each three-element
>> vectors of any magnitude. Compute the angle in degrees as follows:
>>
>> angle = acos( transpose(v1)#v2 / sqrt(total(v1^2)) / sqrt(total
>> (v2^2)) ) * 180./!pi
>>
>> Good luck.
>
> There is an issue with this method due to the fact that acos cannot
> distinguish between positive and negative angles (cos(-theta) = cos
> (theta)).

The angle between two vectors is by definition positive; the question
asked does not provide enough information to assign a sign to the angle.
"Enough information" could be, for instance, a third vector which
defines (via the right-hand rule) which direction of rotation counts as
a clockwise rotation, and which one is counterclockwise.
Re: Calculate the included angle between two vectors [message #65972 is a reply to message #65971] Fri, 10 April 2009 02:15 Go to previous message
duxiyu@gmail.com is currently offline  duxiyu@gmail.com
Messages: 88
Registered: March 2007
Member
Thanks all.


On Apr 10, 1:41 am, Chris <beaum...@ifa.hawaii.edu> wrote:
> On Apr 9, 5:43 am, Pierre <pierre.villene...@gmail.com> wrote:
>
>> On Apr 9, 7:14 am, "dux...@gmail.com" <dux...@gmail.com> wrote:
>
>>> Is there a function which can calculate the included  angle between
>>> two three-dimensional vectors?
>
>>> jdu
>
>> Here's a simple solution.  Assume v1 and V2 are each three-element
>> vectors of any magnitude.  Compute the angle in degrees as follows:
>
>> angle = acos( transpose(v1)#v2 / sqrt(total(v1^2)) / sqrt(total
>> (v2^2)) ) * 180./!pi
>
>> Good luck.
>
> There is an issue with this method due to the fact that acos cannot
> distinguish between positive and negative angles (cos(-theta) = cos
> (theta)).
> I have found this website to be very useful for coding geometry type
> problems like this one:http://local.wasp.uwa.edu.au/~pbourke/geometry/
>
> chris
Re: Calculate the included angle between two vectors [message #65976 is a reply to message #65972] Thu, 09 April 2009 10:41 Go to previous message
Chris[6] is currently offline  Chris[6]
Messages: 84
Registered: July 2008
Member
On Apr 9, 5:43 am, Pierre <pierre.villene...@gmail.com> wrote:
> On Apr 9, 7:14 am, "dux...@gmail.com" <dux...@gmail.com> wrote:
>
>> Is there a function which can calculate the included  angle between
>> two three-dimensional vectors?
>
>> jdu
>
> Here's a simple solution.  Assume v1 and V2 are each three-element
> vectors of any magnitude.  Compute the angle in degrees as follows:
>
> angle = acos( transpose(v1)#v2 / sqrt(total(v1^2)) / sqrt(total
> (v2^2)) ) * 180./!pi
>
> Good luck.

There is an issue with this method due to the fact that acos cannot
distinguish between positive and negative angles (cos(-theta) = cos
(theta)).
I have found this website to be very useful for coding geometry type
problems like this one:
http://local.wasp.uwa.edu.au/~pbourke/geometry/

chris
Re: Calculate the included angle between two vectors [message #65981 is a reply to message #65976] Thu, 09 April 2009 08:43 Go to previous message
Pierre V. is currently offline  Pierre V.
Messages: 13
Registered: December 2006
Junior Member
On Apr 9, 7:14 am, "dux...@gmail.com" <dux...@gmail.com> wrote:
> Is there a function which can calculate the included  angle between
> two three-dimensional vectors?
>
> jdu

Here's a simple solution. Assume v1 and V2 are each three-element
vectors of any magnitude. Compute the angle in degrees as follows:

angle = acos( transpose(v1)#v2 / sqrt(total(v1^2)) / sqrt(total
(v2^2)) ) * 180./!pi

Good luck.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Filling Contour with Patterns
Next Topic: Re: ENVI_INIT_TILE tiling problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:24:06 PDT 2025

Total time taken to generate the page: 0.00594 seconds