解决方案 »

  1.   

    你看msdn,对各个参数都有说明的,在看不懂,百度总会吧
      

  2.   

    我知道各个参数的意思,也百度过了,我的问题是画出的圆弧我没法定位啊??我要求它正好首尾都在两条直线上,成为两条直线的切线弧,我摘抄了一个网上的代码,运行后两条直线出来了,弧线看不见啊。
    Graphics g = this.pictureBox_CurveDivide.CreateGraphics();
     Pen mypen = new Pen(System.Drawing.Color.Black, 2);
     public void DrawArc(Arc arc,Graphics g,Pen mypen)
            {
                XYZ startpoint = FindStartpoint(arc.GetEndPoint(0), arc.GetEndPoint(1));//圆弧的起点也是第一条直线的终点
                XYZ endpoint = FindEndpoint(arc.GetEndPoint(0), arc.GetEndPoint(1));//圆弧的终点也是第二条直线的起点
                XYZ center = arc.Center;//圆弧的圆心坐标
                double r = arc.Radius;//圆弧的半径
                double k = Math.Sqrt((endpoint.X - startpoint.X) * (endpoint.X - startpoint.X) + (endpoint.Y - startpoint.Y) * (endpoint.Y - startpoint.Y));//圆弧起始/终止点之间的直线距离
                double x = center.X - r;
                double y = center.Y - r;
                double width = 2 * r;
                double height = 2 * r;
                RectangleF myrectangle = new RectangleF((float)x, (float)y, (float)width, (float)height);
                double startangle = Math.Atan(startpoint.Y / startpoint.X);
                double sweepangle = 2 * Math.Asin((k / 2) / r);
                g.DrawArc(mypen, myrectangle, (float)startangle, (float)sweepangle);
            }
    大神,求指教~~picturebox上完全看不到弧线。
      

  3.   

    大侠你的意思是我不用Arc本身的属性,而是根据起始/终止点算出相对于弧的圆心,
    然后还是依照我贴的那个代码继续运行吗??只是修改下圆心??
      

  4.   


    public void DrawArc(Arc arc,Graphics g,Pen mypen,float offsety)
            {
                XYZ startpoint = FindStartpoint(arc.GetEndPoint(0), arc.GetEndPoint(1));
                XYZ endpoint = FindEndpoint(arc.GetEndPoint(0), arc.GetEndPoint(1));
                //XYZ center = arc.Center;
                XYZ center = new XYZ((startpoint.X+endpoint.X)/2,(startpoint.Y+endpoint.Y)/2,0);
                double r = arc.Radius;
                //TaskDialog.Show("startpoint", startpoint.ToString());
                //TaskDialog.Show("endpoint", endpoint.ToString());
                //TaskDialog.Show("center", center.ToString());
                //TaskDialog.Show("r", r.ToString());
                double k = Math.Sqrt((endpoint.X - startpoint.X) * (endpoint.X - startpoint.X) + (endpoint.Y - startpoint.Y) * (endpoint.Y - startpoint.Y));
                double x = (center.X - r)*8+0;
                double y = offsety-(center.Y - r)*8;
                double width = 2 * r;
                double height = 2 * r;
                RectangleF myrectangle = new RectangleF((float)x, (float)y, (float)width, (float)height);
                double startangle = Math.Atan(startpoint.Y / startpoint.X);
                double sweepangle = 2 * Math.Asin((k / 2) / r);
                g.DrawArc(mypen, myrectangle, (float)startangle, (float)sweepangle);
            }
    还是不行哎。求指教啊~~
      

  5.   

    不是啊。做弧还是要用DrawArc方法的。但是这个方法不是需要知道那两个角度和圆心么。这个需要你计算啊。我说的那些是计算圆心
      

  6.   

    骚瑞啊,刚想点引用的,不小心点到丢个板砖了。。
    DrawArc(Pen, Rectangle, Single, Single),需要两个角度,圆心用来怎么用,固定Rectangle的位置么??大侠,该怎么固定啊??不太明白,求指教啊~~新人勿怪~~~
      

  7.   

    GraphicsPath gp=new GraphicsPath();
    gp.AddLine();
    gp.AddArc();
    gp.CloseCurver();Graphics.DrawPath(Pens.Red,gp);
      

  8.   

    这大侠这个跟g.drawArc(),差不多啊,需要的参数都是一模一样的,我就是参数问题没法解决现在startangle和sweepangle都解决了,就是rectangle无法定位。
    运行结果图如下:
      

  9.   


    问题已解决,现在发现编程遇到的很多问题还是得靠自己的领悟,依然是用的drawArc方法,只是这次自己的rectangle设置对了,感谢楼上的各位抽出时间回答问题,但是我还是想说作为新手真的有很多不懂得即使自己百度查资料依然还是有不懂得地方,有时候高手的一句话就能点拨我们,希望高手们在回答的时候不要太高冷,万分感谢。