Re: Calculate the included angle between two vectors [message #65971] |
Fri, 10 April 2009 02:47 |
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  |
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  |
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  |
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.
|
|
|