j2me midp1.0 三角函数代码

来源:互联网 发布:现在最流行的网络用语 编辑:程序博客网 时间:2024/04/28 07:15

本次推荐电影下载《神话》

j2me midp1.0 三角函数代码

public class math {

 static int data[] = {
   0, 286, 572, 857, 1143, 1428, 1713, 1997, 2280, 2563,
   2845, 3126, 3406, 3686, 3964, 4240, 4516, 4790, 5063, 5334,
   5604, 5872, 6138, 6402, 6664, 6924, 7182, 7438, 7692, 7943,
   8192, 8438, 8682, 8923, 9162, 9397, 9630, 9860, 10087, 10311,
   10531, 10749, 10963, 11174, 11381, 11585, 11786, 11982, 12176, 12365,
   12551, 12733, 12911, 13085, 13255, 13421, 13583, 13741, 13894, 14044,
   14189, 14330, 14466, 14598, 14726, 14849, 14968, 15082, 15191, 15296,
   15396, 15491, 15582, 15668, 15749, 15826, 15897, 15964, 16026, 16083,
   16135, 16182, 16225, 16262, 16294, 16322, 16344, 16362, 16374, 16382,
   16384
   };
/*x = 50 + 50 * math.cos14(j) / 16384;j是角度,‘math.cos14(j) / 16384’是j 的cos值
    y = 50 + 50 * math.sin14(j) / 16384;*/
   public math()
   {
   }

   public static int sin14(int i)
   {
   int j = i % 360;
   if(j >= 0 && j <= 90)
   return data[j];
   if(j > 90 && j <= 180)
   return data[180 - j];
   j = 359 - j;
   if(j >= 0 && j <= 90)
    return -data[j];
    if(j > 90 && j <= 180)
    return -data[180 - j];
   else
   return 0;
   }

   public static int cos14(int i)
   {
   int j = i % 360;
   if(j >= 0 && j <= 90)
   return data[90 - j];
   if(j > 90 && j <= 180)
   return -data[j - 90];
   j = 359 - j;
   if(j >= 0 && j <= 90)
    return -data[90 - j];
    if(j > 90 && j <= 180)
    return data[j - 90];
   else
   return 0;
   }

   public static int tan14(int i)
   {
   return (sin14(i) << 14) / cos14(i);
   }
   public static int abs(int i) {
   if (i < 0) {
   return -i;
   }
   else {
   return i;
   }
   }
   }

原创粉丝点击