⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 erase.lst

📁 Embedded camera control program.
💻 LST
📖 第 1 页 / 共 5 页
字号:
.................... }  
....................   
.................... #define LN10 2.30258509  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float log10(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the the log base 10 of x  
.................... // Date : N/A  
.................... //  
.................... float log10(float x)  
.................... {  
....................    float r;  
....................   
....................    r = log(x);  
....................    r = r/LN10;  
....................    return(r);  
.................... }  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float modf(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description :breaks the argument value int integral and fractional parts,  
.................... // ach of which have the same sign as the argument.  It stores the integral part  
.................... // as a float in the object pointed to by the iptr  
.................... // Returns : returns the signed fractional part of value.  
.................... // Date : N/A  
.................... //  
....................   
.................... float modf(float value,float *iptr)  
.................... {  
....................    *iptr=(value < 0.0)?ceil(value): floor(value);  
....................    return(value - *iptr);  
.................... }  
....................   
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float pwr(float x,float y)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the value (x^y)  
.................... // Date : N/A  
.................... //  
.................... float pwr(float x,float y)  
.................... {  
....................    if(x>=0)  
....................      return(  exp(y*log(x)) );  
....................    else  
....................      return(  -exp(y*log(-x)) );  
.................... }  
....................   
....................   
.................... //////////////////// Power functions ////////////////////  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float pow(float x,float y)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the value (x^y)  
.................... // Date : N/A  
.................... //  
.................... float pow(float x,float y)  
.................... {  
....................    if(x>=0)  
....................      return(  exp(y*log(x)) );  
....................    else  
....................      return(  -exp(y*log(-x)) );  
.................... }  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float sqrt(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the square root of x  
.................... // Date : N/A  
.................... //  
.................... float sqrt(float x)  
.................... {  
....................    float y, res;  
....................    BYTE *p;  
....................   
....................    #ifdef _ERRNO  
....................    if(x < 0)  
....................    {  
....................       errno=EDOM;  
....................    }  
....................    #endif  
....................   
....................    if( x<=0.0)  
....................       return(0.0);  
....................   
....................    y=x;  
....................    p=&y;  
....................    (*p)=(BYTE)((((int16)(*p)) + 127) >> 1);  
....................   
....................    do {  
....................       res=y;  
....................       y+=(x/y);  
....................       (*p)--;  
....................    } while(res != y);  
....................   
....................    return(res);  
.................... }  
....................   
....................   
....................   
.................... ////////////////////////////// Trig Functions //////////////////////////////  
.................... #undef PI_DIV_BY_TWO  
.................... #define PI_DIV_BY_TWO	1.570796326794896  
.................... #undef TWOBYPI  
.................... #define TWOBYPI 			0.6366197724  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float cos(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the cosine value of the angle x, which is in radian  
.................... // Date : 9/20/2001  
.................... //  
.................... float cos(float x)  
.................... {  
.................... 	float y, t, t2 = 1.0;  
.................... 	int quad, i;  
.................... 	float frac;  
.................... 	float p[4] = {  
.................... 		-0.499999993585,  
.................... 		 0.041666636258,  
.................... 		-0.0013888361399,  
.................... 		 0.00002476016134  
.................... 	};  
....................   
.................... 	if (x < 0) x = -x;                  // absolute value of input  
....................   
.................... 	quad = (int)(x / PI_DIV_BY_TWO);    // quadrant  
.................... 	frac = (x / PI_DIV_BY_TWO) - quad;  // fractional part of input  
.................... 	quad = quad % 4;                    // quadrant (0 to 3)  
....................   
.................... 	if (quad == 0 || quad == 2)  
.................... 		t = frac * PI_DIV_BY_TWO;  
.................... 	else if (quad == 1)  
.................... 		t = (1-frac) * PI_DIV_BY_TWO;  
.................... 	else // should be 3  
.................... 		t = (frac-1) * PI_DIV_BY_TWO;  
....................   
.................... 	y = 0.999999999781;  
.................... 	t = t * t;  
.................... 	for (i = 0; i <= 3; i++)  
.................... 	{  
.................... 		t2 = t2 * t;  
.................... 		y = y + p[i] * t2;  
.................... 	}  
....................   
.................... 	if (quad == 2 || quad == 1)  
.................... 		y = -y;  // correct sign  
....................   
.................... 	return (y);  
.................... }  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float sin(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the sine value of the angle x, which is in radian  
.................... // Date : 9/20/2001  
.................... //  
.................... float sin(float x)  
.................... {  
.................... 	return cos(x - PI_DIV_BY_TWO);  
.................... }  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float tan(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the tangent value of the angle x, which is in radian  
.................... // Date : 9/20/2001  
.................... //  
.................... float tan(float x)  
.................... {  
....................    float c, s;  
....................   
....................    c = cos(x);  
.................... 	if (c == 0.0)  
.................... 	   return (1.0e+36);  
....................   
....................    s = sin(x);  
....................    return(s/c);  
.................... }  
....................   
....................   
....................   
.................... float const pas[3] = {0.49559947, -4.6145309, 5.6036290};  
.................... float const qas[3] = {1.0000000,  -5.5484666, 5.6036290};  
....................   
.................... float ASIN_COS(float x, int n)  
.................... {  
....................    float y, res, r, y2;  
....................    int1 s;  
....................    #ifdef _ERRNO  
....................    if(x <-1 || x > 1)  
....................    {  
....................       errno=EDOM;  
....................    }  
....................    #endif  
....................    s = 0;  
....................    y = x;  
....................   
....................    if (x < 0)  
....................    {  
....................       s = 1;  
....................       y = -y;  
....................    }  
....................   
....................    if (y > 0.5)  
....................    {  
....................       y = sqrt((1.0 - y)/2.0);  
....................       n += 2;  
....................    }  
....................   
....................    y2=y*y;  
....................   
....................    res = pas[0]*y2 + pas[1];  
....................    res = res*y2 + pas[2];  
....................   
....................    r = qas[0]*y2 + qas[1];  
....................    r = r*y2 + qas[2];  
....................   
....................    res = y*res/r;  
....................   
....................    if (n & 2)     // |x| > 0.5  
....................       res = PI_DIV_BY_TWO - 2.0*res;  
....................    if (s)  
....................       res = -res;  
....................    if (n & 1)           // take arccos  
....................       res = PI_DIV_BY_TWO - res;  
....................   
....................    return(res);  
.................... }  
....................   
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float asin(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the arcsine value of the value x.  
.................... // Date : N/A  
.................... //  
.................... float asin(float x)  
.................... {  
....................    float r;  
....................   
....................    r = ASIN_COS(x, 0);  
....................    return(r);  
.................... }  
....................   
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float acos(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the arccosine value of the value x.  
.................... // Date : N/A  
.................... //  
.................... float acos(float x)  
.................... {  
....................    float r;  
....................   
....................    r = ASIN_COS(x, 1);  
....................    return(r);  
.................... }  
....................   
.................... float const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457};  
.................... float const qat[4] = {1.0000000,  11.368190, 28.982246, 19.818457};  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float atan(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the arctangent value of the value x.  
.................... // Date : N/A  
.................... //  
.................... float atan(float x)  
.................... {  
....................    float y, res, r;  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -