求一个角度的sin,cos值的demo

package iodemo;
//求一个角度的sin cos值
public class AngleDemo {
     static  int averageAngle = 3;
static double[] sin;
static double[] cos;
static {
sin = new double[180 / averageAngle + 1];
cos = new double[180 / averageAngle + 1];
sin[0] = 0.0;
sin[1] = 0.05233595624294383;
sin[2] = 0.10452846326765346;
sin[3] = 0.15643446504023087;
sin[4] = 0.20791169081775931;
sin[5] = 0.25881904510252074;
sin[6] = 0.3090169943749474;
sin[7] = 0.35836794954530027;
sin[8] = 0.40673664307580015;
sin[9] = 0.45399049973954675;
sin[10] = 0.49999999999999994;
sin[11] = 0.544639035015027;
sin[12] = 0.5877852522924731;
sin[13] = 0.6293203910498375;
sin[14] = 0.6691306063588582;
sin[15] = 0.7071067811865475;
sin[16] = 0.7431448254773942;
sin[17] = 0.7771459614569708;
sin[18] = 0.8090169943749475;
sin[19] = 0.8386705679454239;
sin[20] = 0.8660254037844386;
sin[21] = 0.8910065241883678;
sin[22] = 0.9135454576426009;
sin[23] = 0.9335804264972017;
sin[24] = 0.9510565162951535;
sin[25] = 0.9659258262890683;
sin[26] = 0.9781476007338057;
sin[27] = 0.9876883405951378;
sin[28] = 0.9945218953682733;
sin[29] = 0.9986295347545738;
sin[30] = 1.0;
sin[31] = 0.9986295347545738;
sin[32] = 0.9945218953682734;
sin[33] = 0.9876883405951377;
sin[34] = 0.9781476007338057;
sin[35] = 0.9659258262890683;
sin[36] = 0.9510565162951536;
sin[37] = 0.9335804264972017;
sin[38] = 0.913545457642601;
sin[39] = 0.8910065241883679;
sin[40] = 0.8660254037844387;
sin[41] = 0.838670567945424;
sin[42] = 0.8090169943749475;
sin[43] = 0.777145961456971;
sin[44] = 0.7431448254773945;
sin[45] = 0.7071067811865476;
sin[46] = 0.669130606358858;
sin[47] = 0.6293203910498374;
sin[48] = 0.5877852522924732;
sin[49] = 0.5446390350150273;
sin[50] = 0.49999999999999994;
sin[51] = 0.45399049973954686;
sin[52] = 0.40673664307580004;
sin[53] = 0.35836794954530066;
sin[54] = 0.3090169943749475;
sin[55] = 0.258819045102521;
sin[56] = 0.20791169081775931;
sin[57] = 0.15643446504023098;
sin[58] = 0.10452846326765373;
sin[59] = 0.05233595624294425;
sin[60] = 0;
cos[0] = 1.0;
cos[1] = 0.9986295347545738;
cos[2] = 0.9945218953682733;
cos[3] = 0.9876883405951378;
cos[4] = 0.9781476007338057;
cos[5] = 0.9659258262890683;
cos[6] = 0.9510565162951535;
cos[7] = 0.9335804264972017;
cos[8] = 0.9135454576426009;
cos[9] = 0.8910065241883679;
cos[10] = 0.8660254037844387;
cos[11] = 0.838670567945424;
cos[12] = 0.8090169943749475;
cos[13] = 0.7771459614569709;
cos[14] = 0.7431448254773942;
cos[15] = 0.7071067811865476;
cos[16] = 0.6691306063588582;
cos[17] = 0.6293203910498375;
cos[18] = 0.5877852522924731;
cos[19] = 0.5446390350150272;
cos[20] = 0.5000000000000001;
cos[21] = 0.45399049973954686;
cos[22] = 0.4067366430758004;
cos[23] = 0.35836794954530016;
cos[24] = 0.30901699437494745;
cos[25] = 0.25881904510252074;
cos[26] = 0.20791169081775923;
cos[27] = 0.15643446504023092;
cos[28] = 0.10452846326765346;
cos[29] = 0.052335956242943966;
cos[30] = 0;
cos[31] = -0.05233595624294384;
cos[32] = -0.10452846326765333;
cos[33] = -0.15643446504023104;
cos[34] = -0.20791169081775912;
cos[35] = -0.25881904510252085;
cos[36] = -0.30901699437494734;
cos[37] = -0.35836794954530027;
cos[38] = -0.4067366430758001;
cos[39] = -0.45399049973954675;
cos[40] = -0.4999999999999998;
cos[41] = -0.5446390350150271;
cos[42] = -0.587785252292473;
cos[43] = -0.6293203910498373;
cos[44] = -0.6691306063588579;
cos[45] = -0.7071067811865475;
cos[46] = -0.7431448254773944;
cos[47] = -0.7771459614569709;
cos[48] = -0.8090169943749473;
cos[49] = -0.8386705679454239;
cos[50] = -0.8660254037844387;
cos[51] = -0.8910065241883678;
cos[52] = -0.913545457642601;
cos[53] = -0.9335804264972016;
cos[54] = -0.9510565162951535;
cos[55] = -0.9659258262890682;
cos[56] = -0.9781476007338057;
cos[57] = -0.9876883405951377;
cos[58] = -0.9945218953682733;
cos[59] = -0.9986295347545738;
cos[60] = -1.0;
for(int i = 0; i < sin.length; i++) {
System.out.println(" sin["+i+"] = " + Math.sin(i * averageAngle / 180.0 * Math.PI)+";");
}
for(int i = 0; i < cos.length; i++) {
System.out.println(" cos["+i+"] = " + Math.cos(i * averageAngle / 180.0 * Math.PI)+";");
}


}





public static void main(String[] args) {
// TODO Auto-generated method stub


}


}

你可能感兴趣的:(Java)