Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

VectorAngle

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89893] VectorAngle
  • From: will parr <willpowers69 at hotmail.com>
  • Date: Tue, 24 Jun 2008 03:26:09 -0400 (EDT)

Dear Math Forum,

I am having a little trouble with determining the angles between 2 vectors using the VectorAngle function. As an example:

centroid = {0, 0, 0};

Xvec = {1, 0, 0};
Yvec = {0, 1, 0};
Zvec = {0, 0, 1};

xaxis = {centroid, Xvec};

yaxis = {centroid, Yvec};

zaxis = {centroid, Zvec};

Show[Graphics[{Thickness[0.01], Blue, Line[xaxis[[All, {1, 2}]]]}], 
 Graphics[{Thickness[0.01], Red, Line[yaxis[[All, {1, 2}]]]}], 
 Graphics[{Thickness[0.01], Green, Line[zaxis[[All, {1, 2}]]]}],
 
 Axes -> True, AxesLabel -> {"x", "y"}]

This displays the x,y,z axes vectors. Then:

vec1 = {-1, 0.2, 0};
vec2 = {-1, -0.2, 0};

Show[Graphics[{Thickness[0.01], Blue, Line[xaxis[[All, {1, 2}]]]}], 
 Graphics[{Thickness[0.01], Red, Line[yaxis[[All, {1, 2}]]]}], 
 Graphics[{Thickness[0.01], Green, Line[zaxis[[All, {1, 2}]]]}],
 
 Graphics[{Thickness[0.01], Orange, 
   Line[{centroid, vec1}[[All, {1, 2}]]]}],
 Graphics[{Thickness[0.01], Purple, 
   Line[{centroid, vec2}[[All, {1, 2}]]]}],
 
 
 Axes -> True, AxesLabel -> {"x", "y"}]

Displays 2 test vectors (vec1 and vec2). Now, using VectorAngle and calculating all angles in degrees (*180/\[Pi]):

VectorAngle[Xvec, vec1]*180/\[Pi]

= 168.69

VectorAngle[Xvec, vec2]*180/\[Pi]

= 168.69

Here is my problem... is there any way to constrain VectorAngle so that it always measures from the first vector to the second vector in the same direction? ie so that the angle given by;

VectorAngle[Xvec, vec2]*180/\[Pi] 

is;

180 + (180 - (VectorAngle[Xvec, vec2]*180/\[Pi]))

= 191.31

Best wishes,

Will


  • Prev by Date: Re: Plot results not right
  • Next by Date: ParameterCITable vs. ParameterConfidenceRegion: rectangular vs.
  • Previous by thread: Re: Symbolic complex conjugation?
  • Next by thread: Re: VectorAngle