咸
咸鱼
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我的一段计算程序。
计算的正确结果应该是h=58.4505,sitac=160,t=55.89997。
可是这段程序的计算结果却是:h=53.5254,sitac=158.1714,t=74.4416。
如果把h=58.4505,sitac=160代入公式中,可以得出t=55.89997,可见公式没有错误,那么造成这种结果的原因只能是h和sitac的计算误差过大。
这该如何处理呢?请各位高手朋友赐教。
多谢!
longdo
uble A1,B1,C1,D1,r1,h1,s1,r2,h2,s2,r3,h3,s3,r4,h4,s4,r5,h5,s5,t,t1,t2,t3;
longdo
uble pi=3.1415926/180.0;
longdo
uble A2,B2,C2,D2,A3,B3,C3,D3;
longdo
uble X1,X2,X3,X4,Y1,Y2,Y3,Y4,E,F,G,h,ss,sitac;
r1=60.82608;h1=55.4160;s1=158.8167*pi;
r2=52.3740;h2=56.5904;s2=159.3864*pi;
r3=57.6858;h3=61.0784;s3=160.8904*pi;
r4=52.9642;h4=61.0030;s4=161.1023*pi;
r5=56.3365;h5=51.0672;s5=157.2643*pi;
A1=r1*r2*h3*sin(s2-s1)+r2*r3*h1*sin(s3-s2)-r1*r3*h2*sin(s3-s1);
B1=r1*r2*sin(s2-s1)+r2*r3*sin(s3-s2)-r1*r3*sin(s3-s1);
C1=r1*(h3-h2)*cos(s1)-r2*(h3-h1)*cos(s2)+r3*(h2-h1)*cos(s3);
D1=r1*(h3-h2)*sin(s1)-r2*(h3-h1)*sin(s2)+r3*(h2-h1)*sin(s3);
A2=r1*r2*h4*sin(s2-s1)+r2*r4*h1*sin(s4-s2)-r1*r4*h2*sin(s4-s1);
B2=r1*r2*sin(s2-s1)+r2*r4*sin(s4-s2)-r1*r4*sin(s4-s1);
C2=r1*(h4-h2)*cos(s1)-r2*(h4-h1)*cos(s2)+r4*(h2-h1)*cos(s4);
D2=r1*(h4-h2)*sin(s1)-r2*(h4-h1)*sin(s2)+r4*(h2-h1)*sin(s4);
A3=r1*r2*h5*sin(s2-s1)+r2*r5*h1*sin(s5-s2)-r1*r5*h2*sin(s5-s1);
B3=r1*r2*sin(s2-s1)+r2*r5*sin(s5-s2)-r1*r5*sin(s5-s1);
C3=r1*(h5-h2)*cos(s1)-r2*(h5-h1)*cos(s2)+r5*(h2-h1)*cos(s5);
D3=r1*(h5-h2)*sin(s1)-r2*(h5-h1)*sin(s2)+r5*(h2-h1)*sin(s5);
X1=A1*C2-A2*C1;
X2=A1*D2-A2*D1;
X3=B1*C2-B2*C1;
X4=B1*D2-B2*D1;
Y1=A1*C3-A3*C1;
Y2=A1*D3-A3*D1;
Y3=B1*C3-B3*C1;
Y4=B1*D3-B3*D1;
E=X1*Y3-X3*Y1;
F=X4*Y1+X3*Y2-X1*Y4-X2*Y3;
G=X2*Y4-X4*Y2;
ss=-F+sqrt(F*F-4*E*G);
sitac=atan(ss/(2*E))+3.1415926;
h=(Y1*sin(sitac)-Y2*cos(sitac))/(Y3*sin(sitac)-Y4*cos(sitac));
t1=A2-B2*h;
t2=C2*sin(sitac);
t3=D2*cos(sitac);
t=t1/(t2-t3);
sitac=sitac/pi;
计算的正确结果应该是h=58.4505,sitac=160,t=55.89997。
可是这段程序的计算结果却是:h=53.5254,sitac=158.1714,t=74.4416。
如果把h=58.4505,sitac=160代入公式中,可以得出t=55.89997,可见公式没有错误,那么造成这种结果的原因只能是h和sitac的计算误差过大。
这该如何处理呢?请各位高手朋友赐教。
多谢!
longdo
uble A1,B1,C1,D1,r1,h1,s1,r2,h2,s2,r3,h3,s3,r4,h4,s4,r5,h5,s5,t,t1,t2,t3;
longdo
uble pi=3.1415926/180.0;
longdo
uble A2,B2,C2,D2,A3,B3,C3,D3;
longdo
uble X1,X2,X3,X4,Y1,Y2,Y3,Y4,E,F,G,h,ss,sitac;
r1=60.82608;h1=55.4160;s1=158.8167*pi;
r2=52.3740;h2=56.5904;s2=159.3864*pi;
r3=57.6858;h3=61.0784;s3=160.8904*pi;
r4=52.9642;h4=61.0030;s4=161.1023*pi;
r5=56.3365;h5=51.0672;s5=157.2643*pi;
A1=r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