FS #6759: Support tan function in calculator plugin. Patch by Luke Blaney.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13070 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dan Everton 2007-04-08 11:22:12 +00:00
parent 9e95e306cd
commit 1322ae02f9
2 changed files with 18 additions and 2 deletions

View file

@ -521,7 +521,7 @@ void transcendFunc(char* func, double* tt, int* ttPower)
*ttPower = 0;
calStatus = cal_normal;
if( func[0] =='s' || func[0] =='S')
if( func[0] =='s' || func[0] =='S'|| func[0] =='t' || func[0] =='T')
sign = SIGN(t);
else {
/* if( func[0] =='c' || func[0] =='C') */
@ -544,6 +544,8 @@ void transcendFunc(char* func, double* tt, int* ttPower)
t = M_PI - t;
if (func[0] =='c' || func[0] =='C')
sign = -1;
else if (func[0] =='t' || func[0] =='T')
t*=-1;
}
else if ( 3*M_PI_2 <= t && t <= M_TWOPI)
t -= M_TWOPI;
@ -561,10 +563,20 @@ void transcendFunc(char* func, double* tt, int* ttPower)
*tt = sign*y;
return;
}
else /* if( func[0] =='c' || func[0] =='C')*/ {
else if( func[0] =='c' || func[0] =='C') {
*tt = sign*x;
return;
}
else /*if( func[0] =='t' || func[0] =='T')*/ {
if(t==M_PI_2||t==-M_PI_2){
calStatus = cal_error;
return;
}
else{
*tt = sign*(y/x);
return;
}
}
}
/* -----------------------------------------------------------------------
@ -658,6 +670,9 @@ void oneOperand(void)
case sci_cos:
transcendFunc("cos", &result, &power);
break;
case sci_tan:
transcendFunc("tan", &result, &power);
break;
case sci_fac:
if (power<0 || power>8 || result<0 )
calStatus = cal_error;

View file

@ -287,3 +287,4 @@ Jacob Gardner
Pascal Briehl
Denis Stanishevskiy
Eddy Coman
Luke Blaney