Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
atan2

Subject: atan2

From: Giuseppe

Date: 30 May, 2011 20:12:03

Message: 1 of 9

hi, i have a series of point of a contour and i have calculated their angles with a=atan2(x,y), than with a*180/pi i calculated the angle in degrees,what is the sense of a -170 degree?? i want the same angle between 0 and 2*pi, can i sum it 360?? thanks

Subject: atan2

From: dpb

Date: 30 May, 2011 20:20:16

Message: 2 of 9

On 5/30/2011 3:12 PM, Giuseppe wrote:
> hi, i have a series of point of a contour and i have calculated their
> angles with a=atan2(x,y), than with a*180/pi i calculated the angle in
> degrees,what is the sense of a -170 degree?? i want the same angle
> between 0 and 2*pi, can i sum it 360?? thanks

doc atan2

Look at the sense of the location of x,y on the unit circle to see the
orientation and salt to suit your coordinate system origin...

--

Subject: atan2

From: Roger Stafford

Date: 30 May, 2011 21:43:02

Message: 3 of 9

"Giuseppe " <giuseppe.donofrio@hotmail.it> wrote in message <is0tmi$p52$1@newscl01ah.mathworks.com>...
> hi, i have a series of point of a contour and i have calculated their angles with a=atan2(x,y), than with a*180/pi i calculated the angle in degrees,what is the sense of a -170 degree?? i want the same angle between 0 and 2*pi, can i sum it 360?? thanks
- - - - - - - - - -
 a = mod(180/pi*atan2(x,y),360);

Roger Stafford

Subject: atan2

From: TideMan

Date: 30 May, 2011 21:48:39

Message: 4 of 9

On May 31, 8:12 am, "Giuseppe " <giuseppe.donof...@hotmail.it> wrote:
> hi, i have a series of point of a contour and i have calculated  their angles with a=atan2(x,y), than with a*180/pi i calculated the angle in degrees,what is the sense of a -170 degree??  i want the same angle between 0 and 2*pi, can i sum it 360?? thanks

phi=atan2(x,y)*180/pi;
phi=phi + (phi<0)*360;

Subject: atan2

From: ImageAnalyst

Date: 30 May, 2011 22:31:57

Message: 5 of 9

Good clever suggestions by TideMana and Roger.
You might also want to know that there is an atand() function that
gives the results in degrees directly instead of in radians, so you
don't have to mess with the pi stuff. You'll still have to add or mod
360 though.

Subject: atan2

From: Roger Stafford

Date: 30 May, 2011 22:46:04

Message: 6 of 9

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <3f6b4d7b-724d-4fb6-a1c9-386619e90c1a@m10g2000yqd.googlegroups.com>...
> Good clever suggestions by TideMana and Roger.
> You might also want to know that there is an atand() function that
> gives the results in degrees directly instead of in radians, so you
> don't have to mess with the pi stuff. You'll still have to add or mod
> 360 though.
- - - - - - - - - - -
  I think you will find that 'atand' can only give angles in the range from -90 to +90 analogous to the way 'atan' works with radians, since it can take only one argument. I have never heard of an 'atan2d' type function so you might be stuck with multiplying by 180/pi.

Roger Stafford

Subject: atan2

From: dpb

Date: 31 May, 2011 04:19:33

Message: 7 of 9

On 5/30/2011 5:46 PM, Roger Stafford wrote:
> ImageAnalyst <imageanalyst@mailinator.com> wrote in message
> <3f6b4d7b-724d-4fb6-a1c9-386619e90c1a@m10g2000yqd.googlegroups.com>...
>> Good clever suggestions by TideMana and Roger.
>> You might also want to know that there is an atand() function that
>> gives the results in degrees directly instead of in radians, so you
>> don't have to mess with the pi stuff. You'll still have to add or mod
>> 360 though.
> - - - - - - - - - - -
> I think you will find that 'atand' can only give angles in the range
> from -90 to +90 analogous to the way 'atan' works with radians, since it
> can take only one argument. I have never heard of an 'atan2d' type
> function so you might be stuck with multiplying by 180/pi.
>
> Roger Stafford

My suggestion was based on fact I figured it wouldn't hurt OP (and might
do some good) to look at the results by quadrant and see what he gets
and work it out from there... :)

--

Subject: atan2

From: Roger Stafford

Date: 31 May, 2011 05:35:19

Message: 8 of 9

dpb <none@non.net> wrote in message <is1q8o$pp6$2@speranza.aioe.org>...
> My suggestion was based on fact I figured it wouldn't hurt OP (and might
> do some good) to look at the results by quadrant and see what he gets
> and work it out from there... :)
- - - - - - - - -
  Yes, you may well be right. Some of us, and that includes myself, all too often write out solutions without presenting the reasoning that leads up to them, and the original posters have no incentive to go through the necessary steps for working it out for themselves.

Roger Stafford

Subject: atan2

From: Giuseppe

Date: 31 May, 2011 09:46:04

Message: 9 of 9

"Roger Stafford" wrote in message <is1umn$ckc$1@newscl01ah.mathworks.com>...
> dpb <none@non.net> wrote in message <is1q8o$pp6$2@speranza.aioe.org>...
> > My suggestion was based on fact I figured it wouldn't hurt OP (and might
> > do some good) to look at the results by quadrant and see what he gets
> > and work it out from there... :)
> - - - - - - - - -
> Yes, you may well be right. Some of us, and that includes myself, all too often write out solutions without presenting the reasoning that leads up to them, and the original posters have no incentive to go through the necessary steps for working it out for themselves.
>
> Roger Stafford
----------------------------------
thanks, i will use
rad=atan2(x,y)
deg=180/pi*mod(rad,2*pi)

Giuseppe D'Onofrio

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us