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 
Return to the default flat view Create a new topic Submit Reply
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 messageGo 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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
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: Fri Oct 10 22:13:53 PDT 2025

Total time taken to generate the page: 1.44379 seconds