Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Plot Angle between Vectors

419 views
Skip to first unread message
Message has been deleted

Peter Pein

unread,
Nov 11, 2005, 3:03:10 AM11/11/05
to
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

G. Raymond Brown

unread,
Nov 11, 2005, 3:05:27 AM11/11/05
to

Florian,

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-

Valeri Astanoff

unread,
Nov 11, 2005, 3:10:01 AM11/11/05
to
Hallo Florian,

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

gardyloo

unread,
Nov 12, 2005, 4:04:14 AM11/12/05
to
I'd just like to note that the DrawGraphics packages are now being
sold on Kagi's site for $50 (link from David Park's site as posted
below). Luckily, I got them before this change was made. We might want
to be careful about pointing people there without telling them the
(relatively new) cost. I love the DrawGraphics paradigm, and the things
it makes easier and nice-looking, but there's no way I'd spend the money
for it.

Curtis O.

G. Raymond Brown

unread,
Nov 12, 2005, 4:08:02 AM11/12/05
to
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-

----- Start Original Message -----
From: gardyloo
Subject: Re: Plot Angle between Vectors

Chris Chiasson

unread,
Nov 13, 2005, 2:18:34 AM11/13/05
to
I second this. I think WRI should buy the DrawGraphics software,
copyright, etc. from David Park (or develop thier own), because theirs
is severely lacking in terms of needed features...

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:

http://www.xmlmind.com/xmleditor/price_list.html

Regards,
--
http://chrischiasson.com/contact/chris_chiasson

gardyloo

unread,
Nov 13, 2005, 2:20:05 AM11/13/05
to
G. Raymond Brown wrote:

>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.

Renan

unread,
Nov 13, 2005, 9:20:55 PM11/13/05
to
On 11/13/05, gardyloo <gard...@mail.wsu.edu> wrote:


> 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

unread,
Nov 13, 2005, 9:23:57 PM11/13/05
to
Purchasers will have extended, perhaps indefinite access to updates. The
main Mathematica page at my site dates the latest release.

David Park
dj...@earthlink.net
http://home.earthlink.net/~djmp/

0 new messages