📄 xiangguan.c
字号:
#include<math.h>
extern signed char x[32],y[32];
float xiangguan()
{
char i;
float Rxy0,Rx0,Ry0,theta,temp;
float x1[32],y1[32];
Rxy0=Rx0=Ry0=theta=temp=0;
for(i=0;i<32;i++) //char型转成float型电压值
{
x1[i]=x[i]/256.0*5.0;
y1[i]=y[i]/256.0*5.0;
}
for(i=0;i<32;i++)
{
Rxy0+=x1[i]*y1[i];
}
Rxy0=Rxy0/32;
for(i=0;i<32;i++)
{
Rx0+=x1[i]*x1[i];
}
Rx0=Rx0/32;
for(i=0;i<32;i++)
{
Ry0+=y1[i]*y1[i];
}
Ry0=Ry0/32;
temp=Rx0*Ry0;
temp=sqrt(temp);
temp=Rxy0/temp;
theta=acos(temp);
theta=theta/3.1415926*180;//弧度转角度
return(theta);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -