Newsgroups: comp.robotics
Path: brunix!news.Brown.EDU!agate!howland.reston.ans.net!torn!mcshub!flex.eng.mcmaster.ca!waled
From: waled@flex.eng.mcmaster.ca (ElHoussaine Waled)
Subject: atan2
Message-ID: <1994Jan6.172409.3032@mcshub.dcss.mcmaster.ca>
Sender: usenet@mcshub.dcss.mcmaster.ca
Nntp-Posting-Host: flex.eng.mcmaster.ca
Organization: McMaster University
Date: Thu, 6 Jan 1994 17:24:09 GMT
Lines: 27

Hi everyone,

Here is the motivation and math. expression of atan2 : 

	When using atan(y/x) you have to be very careful, for example, if y = -1
and x = -1 then atan(y/x) will give you 45 degrees which is wrong because the
right answer is -135 deg. (the signs - cancelled each other in atan(y/x) giving
atan(1) which is 45 deg.). atan2 try to overcome this problem. its definition is :


		 _
		| atan(y/x)             x > 0
		|
atan2(y,x) = 	| sgn(y)*PI/2           x = 0
		|
		| atan(y/2) + sgn(y)*PI x < 0
		|_

So it is not for convenience of writing but for avoiding major problems.

By the way, atan2 is a C callable function, you don't have to write your own if
your using C or C++.

El houssaine Waled



