菜鸟求一个用线程编的正弦曲线代码!!最好能在一个自定义的坐标空间中运行!!

解决方案 »

  1.   

    http://www.2cto.com/kf/201007/52462.html
    先弄明白如何画正弦曲线吧
      

  2.   

     private void Form1_Paint(object sender, PaintEventArgs e)
            {
                DrawSin(e.Graphics);
            }        private void DrawSin(Graphics g)
            {
                Pen p = new Pen(Color.Black, 1);
                int Zoom = 10;  //放大倍数
                Point center = new Point(100, 100); //原点            float x1 = (float)(0 * Math.PI * Zoom / 180 + center.X);
                float y1 = (float)(Math.Sin(0 * Math.PI / 180) * Zoom + center.Y);            g.DrawLine(p, 0, center.Y, 1000, center.Y);  //x坐标轴
                g.DrawLine(p, center.X, 0, center.X , 1000);  //y坐标轴            for (int i = 1; i < 360*5; i++)   //角
                {
                    float x2 = (float)(i * Math.PI * Zoom / 180 + center.X);
                    float y2 = (float)Math.Sin(i * Math.PI / 180) *(-1) * Zoom+center.Y;                
                    g.DrawLine(p, x1, y1, x2, y2);                x1 = x2;
                    y1 = y2;            }
            }