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
Vectors are straightforwardly represented in Mathematica as ordered
lists, as in vectorA={Ax,Ay,Az}. If you prefer the notation typically
used in introductory mathematics and physics courses, you can define
xhat={1,0,0}, yhat={0,1,0}, etc. If you know vector components and want
the angles, it's easy to get them from the definition of the Dot product.
For drawings of vectors, use the Graphics or Graphics3D functions. Or,
you can download David Park's Drawing packages at
http://home.earthlink.net/~djmp/. (There's a lot of other good stuff
there that may help you learn to use Mathematica.)
-GRB-
For non-oriented angles, you could do
something like this :
In[1]:=<<Graphics`
In[2]:=angles[v1_,v2_]:=
With[{a1 = ArcCos[First[v1]/Norm[v1]],
a2 = ArcCos[First[v2]/Norm[v2]]},
If[a1<a2,{a1,a2},-{a1,a2}]];
In[3]:= p0={.2,.2};
p1={1,1};
p2={-.25,.75};
In[6]:=Show[Graphics[{Arrow[p0,p1],Arrow[p0,p2],
Circle[p0,0.1,angles[p1-p0,p2-p0]]},
AspectRatio -> Automatic]];
Out[6]= - Graphics -
hth
V.Astanoff
Curtis O.
Thanks. I was unaware of this change. Not that I find any fault with
David regarding it. He has made an excellent contribution, and it is
reasonable to me that he no longer make it freely available. I would be
willing to pay $50 for the drawing packages, had I not already them in my
possession (and, no, I _don't_ have money to burn!). On the other hand,
I would prefer that it be sold through WRI rather than a 3rd party. Of
course, I'm not privy to any negotiations that took place. I do consider
WRI a national treasure, and want to feel confident that they have the
resources to continue to improve Mathematica. So I would prefer to see
that they share with authors the revenues from derivative products. Of
course, that's only IMHO.
I will in the future warn folks of the cost before sending them to the
site.
-GRB-
----- Start Original Message -----
From: gardyloo
Subject: Re: Plot Angle between Vectors
side note:
The Kagi site does not mention anything about updates for the
package... What about people who buy the package shortly before a new
version is released? Maybe Mr. Park would consider a pricing and
upgrade scheme like the one linked below:
>Curtis,
>
>Thanks. I was unaware of this change. Not that I find any fault with
>David regarding it. He has made an excellent contribution, and it is
>reasonable to me that he no longer make it freely available. I would be
>willing to pay $50 for the drawing packages, had I not already them in my
>possession (and, no, I _don't_ have money to burn!). On the other hand,
>I would prefer that it be sold through WRI rather than a 3rd party. Of
>course, I'm not privy to any negotiations that took place. I do consider
>WRI a national treasure, and want to feel confident that they have the
>resources to continue to improve Mathematica. So I would prefer to see
>that they share with authors the revenues from derivative products. Of
>course, that's only IMHO.
>
>I will in the future warn folks of the cost before sending them to the
>site.
>
>-GRB-
>
>
Agreed. Mr. Park's solutions are invariably helpful and interesting.
If he makes some profit from the Kagi site, more power to him. From what
I've seen, several other people from the list could do analogous
marketing. As for myself, I might be able to afford some of the packages
once I get out of grad. school!
Regards,
Curtis O.
> Agreed. Mr. Park's solutions are invariably helpful and interesting.
> If he makes some profit from the Kagi site, more power to him. From what
> I've seen, several other people from the list could do analogous
> marketing. As for myself, I might be able to afford some of the packages
> once I get out of grad. school!
>
> Regards,
> Curtis O.
What I'd like to see is a "Lite" version of the package, for the
occasional user (like me and many others).
E.g. I hardly use the 3D features in DrawGraphics, so there could be a
2D-only version of DrawGraphics that is cheaper.
--
Thanks/obrigado, Renan "Wishmaster" Birck - Canoas, Rio Grande do Sul, Brasil
MSN: wizard_o...@hotmail.com
Orkut: http://www.orkut.com/Profile.aspx?uid=2202360379963855296
David Park
dj...@earthlink.net
http://home.earthlink.net/~djmp/