分享

新手求一个完成的C#画渐开螺旋线代码

 牛人的尾巴 2016-06-10
C# code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public partial class Form1 : Form
{
    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer() { Interval = 200};
    List<PointF> points = new List<PointF>();
    public Form1()
    {
        InitializeComponent();
        this.DoubleBuffered = true;
        this.timer.Tick += (o, e) => this.Invalidate();
        this.timer.Start();
    }
    protected override void OnPaint(PaintEventArgs e)
    {
        if (points.Count < 100)
        {
            int t = points.Count + 1;
            float x =  t * (float)Math.Cos(t / 5f);
            float y =  t * (float)Math.Sin(t / 5f);
            PointF p = new PointF(this.ClientRectangle.Width / 2 + x, this.ClientRectangle.Height / 2 + y);
            points.Add(p);
        }
        if (points.Count > 2)
        {
            e.Graphics.DrawCurve(Pens.Blue, points.ToArray());
        }
    }
}




上楼是螺线,如果是‘圆的渐开线’,则公式为(http://zh./wiki/%E6%BC%B8%E4%BC%B8%E7%B7%9A):
x = cos(t) + t * sin(t);
y = sin(t) - t * cos(t);

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多