绘制摆线的曲线

时间:2018-03-22 15:18:11

标签: c# winforms geometry zedgraph

一天中的好时光。有必要绘制摆线图,半径由用户指定。管理只画了一半的时间,我不明白它是什么。

Code'm apply。

我的功能:

return r * Math.Acos((r - y) / r) - Math.Sqrt(2 * r * y - Math.Pow(y, 2)); 

我的主要部分:

GraphPane pane = zedGraph.GraphPane;

            pane.CurveList.Clear();

            PointPairList list = new PointPairList();

            double r = 20;
            double xmax = 50;

            for (double y = 0; y < xmax; y+=0.5)
            {

                list.Add(CountIt(y, r), y);
            }

            LineItem myCurve = pane.AddCurve("Cycloid", list, Color.Red, SymbolType.None);

            zedGraph.AxisChange();

            zedGraph.Invalidate();

enter image description here

显然有必要考虑y> 2r的情况,或者应该是几个可能的x?我不明白如何摆脱这种情况。

1 个答案:

答案 0 :(得分:1)

使用参数方程(一个句点USE AdventureWorks2012; GO SELECT BusinessEntityID, YEAR(QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota, LAG(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS PreviousQuota FROM Sales.SalesPersonQuotaHistory WHERE BusinessEntityID = 275 and YEAR(QuotaDate) IN ('2005','2006'); )更简单:

t=0..2*Pi

如果你想继续使用笛卡尔方程x(y) - 将x = r * (t - sin(t)) y = r * (1 - cos(t)) 的限制更改为更正值y并像这样镜像第二部分:

2 * r

如果您需要绘制几个句点,请限制xmax:

 for (double y = 0; y < 2 * r; y+=0.5)
        {
            list.Add(CountIt(y, r), y);
        }
 for (double y = 2 * r; y >= 0; y-=0.5)
        {
            list.Add(2 * Pi * r - CountIt(y, r), y);
        }