CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

math.h correction for atan2 in 2nd quadrant

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Kurt Franke
Guest







math.h correction for atan2 in 2nd quadrant
PostPosted: Tue Dec 17, 2002 2:00 pm     Reply with quote

in math.h, the results for atan2 calls that are in the 2nd
quadrant are false. In the second quadrant the return should
be:

return (PI-atan(z));

here's the snippet of code from math.h. Changes are in lines
632, 633 for my version.

I told ccs about this before, but they seem only to have added
the correct line as a comment..

-Kurt


--
z=y/x;
switch(quad)
{
case 1:
{
return atan(z);
break;
}
case 2:
{
// return (atan(z)+PI_DIV_BY_TWO);
return (PI-atan(z)); // correction
break;
}
case 3:
{
return (atan(z)-PI);
break;
}
case 4:
{
return (-atan(z));
break;
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 10101
Hans Wedemeyer
Guest







Re: math.h correction for atan2 in 2nd quadrant
PostPosted: Tue Dec 17, 2002 10:15 pm     Reply with quote

That's strange ! I don't have any code like that in math.h
Which version are you using ?

I ame using V3.129
___________________________
This message was ported from CCS's old forum
Original Post ID: 10108
Kurt Franke
Guest







Re: math.h correction for atan2 in 2nd quadrant
PostPosted: Wed Dec 18, 2002 8:08 am     Reply with quote

:=That's strange ! I don't have any code like that in math.h
:=Which version are you using ?
:=
:=I ame using V3.129

3.129 here also. That is strange. Maybe the installer didn't
remove the old file on my system??

-Kurt
___________________________
This message was ported from CCS's old forum
Original Post ID: 10116
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: math.h correction for atan2 in 2nd quadrant
PostPosted: Wed Dec 18, 2002 1:47 pm     Reply with quote

:=:=That's strange ! I don't have any code like that in math.h
:=:=Which version are you using ?
:=:=
:=:=I ame using V3.129
:=
:=3.129 here also. That is strange. Maybe the installer didn't
:=remove the old file on my system??
---------------------------------------------------------

It's in there. I deleted math.h and re-installed PCM vs. 3.129.
In the atan2 function, at line 630, it has this code:

<PRE>
case 2:
{
return (atan(z)+PI_DIV_BY_TWO);
// return (PI-atan(z));
break;
}
</PRE>

Hans uses PCH. Maybe PCH has a different version of math.h ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 10125
Hans Wedemeyer
Guest







What's going on ?
PostPosted: Thu Dec 19, 2002 3:46 pm     Reply with quote

:=Hans uses PCH. Maybe PCH has a different version of math.h

Almost correct, I use PCWH which includes all compilers.

Doing a search for math.h, I found an old example under pcw, which is where PCWH cames from, and there I found the atan2() that you have talked about !

In the help it mentions Ex_Tank.c as an example for atan2(),
when I load Ex_Tank.c I don't see a direct call to atan2() ! but, I get an error for pwr() function call!

I checked the include setup in the IDE and it does not point to the old PCW ....

This is strange !
When I get time I will clean out the CCS installations and start again !
___________________________
This message was ported from CCS's old forum
Original Post ID: 10149
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group