Pen CurvePan = new Pen(currentColor, 2); if(p1.X>p1.X) { PointF ptem = new PointF(); ptem=p1; p1=p2; p2=ptem; } double instance =Math.Sqrt( (p1.X - p2.X) * (p1.X - p2.X) - (p1.Y - p2.Y) * (p1.Y - p2.Y)); int height = Convert.ToInt16( Math.Abs(p1.Y - p2.Y)); int width=Convert.ToInt16( Math.Abs(p1.X - p2.X)); int total = height ; PointF[] CurrP = new PointF[total]; double R = instance / 2.0f + height / 3.0f;
for (int i = 0; i < total; i++) { float x = p1.X +(width/(total+.01f))*i; float y = p1.Y + (float)Math.Sqrt(R * R - x * x); PointF pch= new PointF(x, y); CurrP[i] = pch; } g.DrawCurve(CurvePan, CurrP, 0.1f); 我的算法,结果不能连结两点
PointF[] CurrP = new PointF[2]{A(x1,y1),B(x2,y2) }; g.DrawCurve(CurvePan, CurrP); 就可以了这是两点的 多的话就这样 List<PointF> list = new List<PointF>(); PointF pt0 = new PointF(x0,y0); list.add(pt0); PointF pt2 = new PointF(x1,y1); list.add(pt1); PointF pt2 = new PointF(x2,y2); list.add(pt2); PointF pt3 = new PointF(x3,y3); list.add(pt3); PointF[] ptdfdf = new PointF[list.Count]; list.CopyTo(ptdfdf); if (ptdfdf.Length > 1) { for (int i = 0; i < list.Count; i++) { g.DrawCurve(new Pen(cuvecolor), ptdfdf); } }
{
PointF ptem = new PointF();
ptem=p1;
p1=p2;
p2=ptem;
} double instance =Math.Sqrt( (p1.X - p2.X) * (p1.X - p2.X) - (p1.Y - p2.Y) * (p1.Y - p2.Y)); int height = Convert.ToInt16( Math.Abs(p1.Y - p2.Y)); int width=Convert.ToInt16( Math.Abs(p1.X - p2.X)); int total = height ; PointF[] CurrP = new PointF[total]; double R = instance / 2.0f + height / 3.0f;
for (int i = 0; i < total; i++)
{
float x = p1.X +(width/(total+.01f))*i;
float y = p1.Y + (float)Math.Sqrt(R * R - x * x);
PointF pch= new PointF(x, y);
CurrP[i] = pch;
}
g.DrawCurve(CurvePan, CurrP, 0.1f);
我的算法,结果不能连结两点
}; g.DrawCurve(CurvePan, CurrP);
就可以了这是两点的
多的话就这样
List<PointF> list = new List<PointF>();
PointF pt0 = new PointF(x0,y0);
list.add(pt0);
PointF pt2 = new PointF(x1,y1);
list.add(pt1);
PointF pt2 = new PointF(x2,y2);
list.add(pt2);
PointF pt3 = new PointF(x3,y3);
list.add(pt3);
PointF[] ptdfdf = new PointF[list.Count];
list.CopyTo(ptdfdf);
if (ptdfdf.Length > 1)
{
for (int i = 0; i < list.Count; i++)
{
g.DrawCurve(new Pen(cuvecolor), ptdfdf);
}
}
是什么意思啊?
听该是double instance =Math.Sqrt( (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y));吧