void DrawSinLine(Graphics gph,Pen p)
        {
            //1. 中心原点 260 150   以120像素高 为单位1  以120像素宽为pi
            double d = -6.2;
            while (d <= 6.283)
            {
                double dbl = Math.Sin(d);

                //Console.WriteLine("sin:{0}",dbl);

                //计算坐标 120 为pi 

                double px, py;
                if (d < 0)
                {
                    px = 250 - Math.Abs(d) * 120 / Math.PI;  // x
                }
                else
                {
                    px = d * 120 / Math.PI + 250;
                }

                //----------------计算y的坐标
                if (dbl < 0)
                {
                    py = Math.Abs(dbl) * 120 + 140;            //y
                }
                else
                {
                    py = 140 - (dbl * 120);
                }

                int x = (int)px + 10;
                int y = (int)py + 10;
                //Console.WriteLine("sin:x=>{0},y=>{1}", x, y);
                p.Color = Color.Black;
                gph.DrawLine(p, x, y, x, y);
                d += 0.02;
            }
            p.Dispose();   //释放资源
            gph.Dispose();
           
        }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
  • 2021-12-09
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-25
  • 2021-07-11
  • 2022-12-23
  • 2021-06-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案