C#画图怎样画三角函数的图啊(带坐标,的波浪图形),俺现在只会画直线

解决方案 »

  1.   

    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
    int unit = 40;//放大倍数
    float interval = 0.01F; //步进刻度,值越小越精确(必须大小0),但速度也越慢
    PointF o = new PointF(this.pictureBox1.Width / 2, this.pictureBox1.Height / 2);
    e.Graphics.DrawLine(Pens.Black, 0, this.pictureBox1.Height / 2, this.pictureBox1.Width, this.pictureBox1.Height / 2);
    e.Graphics.DrawLine(Pens.Black, this.pictureBox1.Width / 2, 0, this.pictureBox1.Width / 2, this.pictureBox1.Height);
    for (float d = -6.28F; d < 6.28F; d += interval)
    {
    float x1 = o.X + d * unit;
    float x2 = o.X + (d + interval) * unit;
    float y1 = o.Y - (float)(unit * System.Math.Sin(d));
    float y2 = o.Y - (float)(unit * System.Math.Sin(d + interval));
    PointF p1 = new PointF(x1, y1);
    PointF p2 = new PointF(x2, y2);
    e.Graphics.DrawLine(Pens.Black, p1, p2);
    }
    }
      

  2.   

    用这个吧:ibqsMath 数学专家组件 v1.4
    http://www.wfsoft.com/wf_ibqsMath.asp
      

  3.   

    只要有数学函数就可以画,用DrawLine()方法画首尾相连的线