Would be grateful for any help rendered. Thanks!
Derek
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)[[1]]+(p2-p1)[[2]] 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
?ArcTan
"ArcTan[z] gives the arc tangent of the complex number z. ArcTan[x, y] gives
\
the arc tangent of y/x, taking into account which quadrant the point (x, y)
\
is in."
Thus:
ArcTan[0, 3]
Pi/2
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
h...@haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
"Blitzer" <drek...@yahoo.com> wrote in message
news:8vfqv9$j...@smc.vnet.net...
In[49]:=
For[a = 0,a <=360,
x = Cos[a Degree];
y = Sin[a Degree];
q = ArcTan[x,y] / Degree;
q = If[q < 0,360+q,q];
Print[a," ",N[q]];
a += 45]
-- prints the input and output angles in the range 0 - 360 degrees.
--
Paul Lutus
www.arachnoid.com
Strictly speaking, it is not possible to define an "angle" between two
"points"- a line yes, but not an angle. Now if you are assuming that there
is a third point common to both (i.e., an origin), _then_ you can define
an angle.
To check for perpendicularity, use the definition of the dot product:
A.B = |A||B|Cos[theta]
where |x| represents the magnitude of x.
Which leads to:
theta = ArcCos[(A.B)/(|A||B|)]
If the "vectors" are perpendicular, theta will equal zero.
Alternately, to determine an angle you could use the definitions of either
the Sine or Cosine functions. This, however, entails determining the
length of the hypotenuse (a minor extra step).
J. Leko
Please e-mail replies to leko*j...@cspar.uah.edu and remove the *
Use ArcTan[(x1-x2),(y1-y2)]
Peter
--
=--=--=--=--=--=--=--=--=--=--=--=--=--= http://home.t-online.de/home/phbrf
Peter Breitfeld, Bad Saulgau, Germany Meinen GnuPG/PGP-5x Key gibts hier
Try the alternate version of ArcTan, ArcTan[x,y]. See Help under
ArcTan.
In[31]:=
x1 = 3;
y1 = 4;
x2 = 3;
y2 = 6;
(180/Pi)*ArcTan[(x2 - x1), (y2 - y1)]
(180/Pi)*ArcTan[(x1 - x2), (y1 - y2)]
Out[35]=
90
Out[36]=
-90
Adam Smith
In article <8vfqv9$j...@smc.vnet.net>,
"Blitzer" <drek...@yahoo.com> wrote:
Sent via Deja.com http://www.deja.com/
Before you buy.
ArcTan[x2-x2,y2-y2]
?
Be careful with the argument order it is opposite to the
atan2 function other languages.
Regards
Jens
use the ArcTan[dx,dy] instead of ArcTan[dy/dx].
Lookup the help browser !
Greetings from Croatia,
Drago Ganic
"Blitzer" <drek...@yahoo.com> wrote in message news:8vfqv9$j...@smc.vnet.net...