Replace unreliable 'divide-by-zero' way of generating NaNs with math.h NAN in deuler routines. (#668)

This commit is contained in:
jmpenn 2018-09-17 11:04:53 -05:00 committed by GitHub
parent 00b4b2c8d9
commit 9a5ecd1294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 12 additions and 24 deletions

View File

@ -120,13 +120,12 @@ int euler123(
/* Error: Out of normal range and beyond tolerance
for asin function */
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -116,13 +116,12 @@ int euler123_quat(
/* Error: Out of normal range and beyond tolerance
for asin function */
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -137,13 +137,12 @@ int euler132(
* for asin function
*/
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -117,13 +117,12 @@ int euler132_quat(
* for asin function
*/
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -124,13 +124,12 @@ int euler213(double angle[3], /* In: r Method=0, 0=PITCH , 1=ROLL , 2=YAW */
/* Error: Out of normal range & beyond tolerance
for asin func */
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -114,13 +114,12 @@ int euler213_quat(
/* Error: Out of normal range & beyond tolerance
for asin func */
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -120,13 +120,12 @@ int euler231( /* Return: -- None. */
}
/* Error: Out of normal range & beyond tolerance for asin func*/
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -112,13 +112,12 @@ int euler231_quat(
}
/* Error: Out of normal range & beyond tolerance for asin func*/
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -118,13 +118,12 @@ int euler312(
}
/* Error: Out of normal range & beyond tolerance for asin func*/
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -112,13 +112,12 @@ int euler312_quat(
}
/* Error: Out of normal range & beyond tolerance for asin func*/
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -120,13 +120,12 @@ int euler321(
}
/* Error: Out of normal range & beyond tolerance for asin func*/
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {

View File

@ -112,13 +112,12 @@ int euler321_quat(
}
/* Error: Out of normal range & beyond tolerance for asin func*/
else {
double zero = 0.0;
ret = TM_ANG_NAN;
if ( error_flag[4] == 0 ) {
tm_print_error(ret);
error_flag[4]=1;
}
angle[0] = angle[1] = angle[2] = 0.0 / zero;
angle[0] = angle[1] = angle[2] = NAN;
}
#undef TOLERANCE
} else if (method == 2) {