MathGroup Archive 2008

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

Search the Archive

Re: VectorAngle

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90023] Re: VectorAngle
  • From: Norbert Marxer <marxer at mec.li>
  • Date: Thu, 26 Jun 2008 04:45:57 -0400 (EDT)
  • References: <g3q7mc$ajm$1@smc.vnet.net>

On 24 Jun., 09:28, will parr <willpower... at hotmail.com> wrote:
> Dear Math Forum,
>
> I am having a little trouble with determining the angles between 2 vector=
s 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 calcu=
lating 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 i=
t always measures from the first vector to the second vector in the same di=
rection? 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

Hello

In 2D you can use the functions ArcTan (with 2 arguments) and Mod (to
restrict the angles to the interval from 0 to 360 Degrees; otherwise
your angles would be in the interval from -180 to +180 Degrees):

    myVectorAngle[v1_, v2_] =  Mod[ArcTan[v2[[1]], v2[[2]]] -
ArcTan[v1[[1]], v1[[2]]], 2*Pi]

Here we assume that the positive z-axis is the axis of rotation and we
count the angles of rotation counterclockwise.

In 3D you would have to specify your axis of rotation to be determine
the absolute angle.

Best Regards
Norbert Marxer


  • Prev by Date: Re: Export PDF plot or Save Selection As -- big troubles with Illustrator
  • Next by Date: Re: Ploting integral curves
  • Previous by thread: Re: VectorAngle
  • Next by thread: ParameterCITable vs. ParameterConfidenceRegion: rectangular vs.