       Re: Problem with finding angles between points in Cartesian plane

• To: mathgroup at smc.vnet.net
• Subject: [mg26110] Re: Problem with finding angles between points in Cartesian plane
• From: Yossi Lonke <jrl16 at po.cwru.edu>
• Date: Tue, 28 Nov 2000 01:55:57 -0500 (EST)
• Organization: Case Western Reserve University, Cleveland, OH, USA
• References: <8vfqv9\$jif@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hello Blitzer,

You say you want the angle between two points, but you are in fact
calculating something else. If p1,p2 are points in the plane, then the
angle between them customarily refers to the angle between the vectors
originating at the origin and ending at those points. The cosine of the
angle is then (p1.p2)/Sqrt[(p1.p1)*(p2.p2)] and that never produces an angle
of 90 degrees for points lying on the same vertical line.
What you are in fact trying to calculate, is the angle that the vector p2-p1
makes with the x-axis. To do that quickly, you might want to try complex
numbers: If p1=(x1,y1) and p2=(x2,y2) try

blitzerAngle[p1_,p2_]:=Arg[(p2-p1)[]+(p2-p1)[] I]

This function calculates the argument of the complex number
(x2-x1)+(y2-y1)*I, where I = Sqrt[-1]. That will give you the desired 90
degrees for points having the same x coordinate.

Yossi Lonke

> From: "Blitzer" <drek1976 at yahoo.com>
To: mathgroup at smc.vnet.net
> Organization: Steven M. Christensen and Associates, Inc and MathTensor, Inc.
> Newsgroups: comp.soft-sys.math.mathematica
> Date: 22 Nov 2000 02:00:57 -0500
> Subject: [mg26110] Problem with finding angles between points in Cartesian plane
>
> 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
>
>
>
>

```

• Prev by Date: Re: vector multiplication
• Next by Date: Computeralgebra in University physics teaching
• Previous by thread: Re: Problem with finding angles between points in Cartesian plane
• Next by thread: Re: Problem with finding angles between points in Cartesian plane