View previous topic :: View next topic |
Author |
Message |
Kurt Franke Guest
|
math.h correction for atan2 in 2nd quadrant |
Posted: Tue Dec 17, 2002 2:00 pm |
|
|
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 |
Posted: Tue Dec 17, 2002 10:15 pm |
|
|
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 |
Posted: Wed Dec 18, 2002 8:08 am |
|
|
:=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
|
Re: math.h correction for atan2 in 2nd quadrant |
Posted: Wed Dec 18, 2002 1:47 pm |
|
|
:=:=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 ? |
Posted: Thu Dec 19, 2002 3:46 pm |
|
|
:=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 |
|
|
|