Home > Back-end >  Triangle in the C language function calls to fail
Triangle in the C language function calls to fail

Time:01-16

In TI DSP 6701 recently wrote a geodetic coordinate system on the platform of high Angle calculation function, which use the trigonometric function atan, found the first few times call program execution is normal, but after two rounds, subsequent calls, returns the results are not in line with expectations, and after a preliminary screening program is normal, when error stack overflow, still do not know what is the problem, Montana ask everybody to give directions!

CodePudding user response:

The standard library has this kind of question is I don't believe
Suggest to add print posted debugging results

CodePudding user response:

refer to the original poster Kelvin_001 response:
in TI DSP 6701 recently wrote a geodetic coordinate system on the platform of high Angle calculation function, which use the trigonometric function atan, found the first few times call program execution is normal, but after two rounds, subsequent calls, returns the results are not in line with expectations, and after a preliminary screening program is normal, when error stack overflow, still do not know what is the problem, Montana ask everybody to give directions!

Thank you for your invitation, this result is not in line with expectations, with only the above said these are difficult to infer the problem
Must first rule out the standard function may go wrong
That is from the parameters of to, have no idea about this platform, can't help you

CodePudding user response:

By comparing error area code is not normal procedures rewrite, and program structure complicated, feeling is called link out of the question, but don't know how to troubleshoot

CodePudding user response:

Add debugging tool, called atan input and output are printed not can determine atan problems or other issues?
reference Kelvin_001 reply: 3/f
by comparing when something goes wrong area code is not normal procedures rewrite, and program structure complicated, feeling is called link has a problem, but don't know how to troubleshoot

CodePudding user response:

Need to convert radian

CodePudding user response:

Unit is no problem, is a radian, the key is the front two call atan function return value is correct, after twice is not in accordance with the input to, even the same input,

CodePudding user response:

Atan, atan2
Calculates the arctangent of x (atan) or the arctangent of y/x (atan2).

Double atan (double x);

Double atan2 (double y, double x);

The Routine of Required Header Compatibility
Atan & lt; math.h> ANSI, Windows 95, Windows NT
Atan2 & lt; math.h> ANSI, Windows 95, Windows NT


For additional compatibility information, see compatibility in the the Introduction.

Libraries

LIBC. LIB Single thread static library, retail version
LIBCMT. LIB Multithread static library, retail version
MSVCRT. LIB Import library for MSVCRT DLL, retail version


The Return Value

Atan returns the arctangent of x. atan2 returns the arctangent of y/x, If x is 0, atan returns 0. If both the parameters of atan2 are 0, the function returns 0. You can modify the error handling by using the _matherr routine. The atan returns a value in the range of PI/2 PI/2 radians), Atan2 returns a value in the range of PI to PI radians, using the signs of both the parameters to determine the quadrant of the return value.

The Parameters

X, y

Any Numbers

Few

The atan function calculates The arctangent of x. atan2 calculates The arctangent of y/x atan2 is well defined for every point other than The origin, even if x and y does not equal 0 equals 0.

Example

/* ATAN. C: This program calculates the
* the arctangent of 1 and 1.
*/

#include
#include
#include

Void main (void)
{
Double x1, x2, y;

Printf (" Enter a real number: ");
Lf the scanf (" % ", & amp; The x1);
Y=atan (x1);
The Arctangent of printf (" % f, % f \ n ", x1, y);
Printf (" Enter a second real number: ");
Lf the scanf (" % ", & amp; X2);
Y=atan2 (x1, x2);
Printf (" the Arctangent of % f/% f, % f \ n ", x1, x2, y);
}


The Output

Enter a real number: 862.42
The Arctangent of - 862.420000:1.569637
Enter a second real number: 78.5149
The Arctangent of - 862.420000/78.514900:1.480006


Floating - Point Support Routines

See Also a cosine, asin, cos, _matherr, sin, tan

CodePudding user response:

I think the building or the code and results posted to see better

CodePudding user response:

The landlord to solve the problem, it seems I also encountered similar problems, for advice

CodePudding user response:

Very sniffy about this question too overestimate their Chinese level,
  • Related