Re: Problem with finding angles between points in Cartesian plane
- To: mathgroup at smc.vnet.net
- Subject: [mg26087] Re: [mg26060] Problem with finding angles between points in Cartesian plane
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Tue, 28 Nov 2000 01:55:32 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
When I saw your question I could not understand what you meant by the
"angle between two points"? There is really no such thing. At first I
assumed you meant the angle between the two vectors corresponding to two
points, but looking at your formula I realized that you seemed to mean the
angle that the line through the two points makes with the x-axis (?).
Well, here is one (out of very many) ways that will compute this without
running into your problem:
angle[P_, Q_] := Arg[(Q - P).{1, I}]
Now we get:
In[3]:=
angle[{3, 4}, {3, 5}]
Out[3]=
Pi/2
However, this angle actually depend on the order in which the points are
given:
In[4]:=
angle[{3, 5}, {3, 4}]
Out[4]=
-(Pi/2)
If you prefer the answer not to depend on the order of the points you can do
this:
ClearAll[angle]
SetAttributes[angle, Orderless]
angle[P_, Q_] := Arg[(Q - P).{1, I}]
Now we get:
In[8]:=
angle[{3, 5}, {3, 4}]
Out[8]=
Pi/2
In[9]:=
angle[{3, 4}, {3, 5}]
Out[9]=
Pi/2
Another possible objection may be that this does definition of angle does
not work with symbolic expressions, in other words with your original
example we get:
In[13]:=
angle[{x1, y1}, {x1, y2}]
Out[13]=
Arg[I*(-y1 + y2)]
This however is really the way it should be since Mathematica know nothing
about y1 and y2 (they might be equal or complex !). In such cases its best
to apply FullSimplify:
In[14]:=
FullSimplify[%, y2 > y1]
Out[14]=
Pi/2
--
Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/
on 00.11.22 3:55 PM, Blitzer at drek1976 at yahoo.com wrote:
> I would like to find the angle between 2 points on the Cartesian plane.
> However, if I use "ArcTan", it is not able to recognise that points with the
> same x-coordinates have an angle of 90 degrees between them. It returns
> "Indeterminate".
> eg. for a point A (x1, y1) and a point (x1, y2), to find the angle between
> them, I use ArcTan[(y2-y1)/(x1-x1)]. However, as the denominator is equal to
> "0", this function returns "indeterminate". Is there a way to get around
> this problem? Or is there other possible functions which can be used.
> I am dealing with a very large array of numbers and thus, it's not possible
> to check the coordinates individually.
>
> Would be grateful for any help rendered. Thanks!
>
> Derek
>
>
>
>
>