MathGroup Archive 2005

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

Search the Archive

Re: Plot Angle between Vectors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62091] Re: Plot Angle between Vectors
  • From: Peter Pein <petsie at dordos.net>
  • Date: Fri, 11 Nov 2005 02:51:54 -0500 (EST)
  • References: <dkuvk6$7pj$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Florian schrieb:
> I am a newbie to Mathematica, and i try to plot two vectors with the
> angle in-between. I could not find a code how to plot angles at all!
> Would be great if someone could help! Thanks a lot.
> 

Hi Florian,

the following function constructs a Graphics object containing 2 Arrows 
and an arc from the first to the second vector:

In[1]:=
VectorAngle[v1_,v2_]:=
   Graphics[Append[Arrow[{0,0},#]&/@{v1,v2},
       Circle[{0,0},Sqrt@Min[#1^2+#2^2&@@@{v1,v2}]/5,
         If[GreaterEqual@@##,{0,2Pi}+##,##]&[ArcTan@@@{v1,v2}]]]]

an example:

In[2]:=
FullForm[VectorAngle[{3, 2}, {-1, 4}]]
Out[2]//FullForm=
FullForm[Graphics[
   {Arrow[{0, 0}, {3, 2}], Arrow[{0, 0}, {-1, 4}],
    Circle[{0, 0}, Sqrt[13]/5, {ArcTan[2/3], Pi - ArcTan[4]}]}]]

usage:

Show[VectorAngle[{3, 2}, {-1, 4}], AspectRatio -> 1, Axes -> True]

or

Show[VectorAngle[{-1, 4}, {3, 2}], AspectRatio -> 1, Axes -> True]

Peter


  • Prev by Date: Re: Plot Angle between Vectors
  • Next by Date: Re: ((a&&b)||c)==((a||c)&&(b||c)) is not true
  • Previous by thread: Re: Plot Angle between Vectors
  • Next by thread: Re: Re: Plot Angle between Vectors