3

我在尝试实现绘制圆弧时遇到了一些麻烦。基本上它应该像在 AutoCAD 中绘制 3 点圆弧一样绘制。我可以从 -180 度到 360 度的开始和结束角度绘制弧线,但如果我尝试超过 -180 度,弧线会翻转到 +180 度。我的问题是当角度超过-180 时我需要弧线继续。除了计算起始角度和结束角度之外,我在代码中的所有内容(我认为)都是正确的。提前感谢您的帮助。这是我的代码:

private void DrawArc()
{
    //fyi linept is of type List<Point3D>();

    Point3D currentPoint = (Point3D)GetPoints(e);
    double rad;
    Point3D center = GetCenterOfCircle(linept.ElementAt(0), linept.ElementAt(1), currentPoint, out rad);
    PieSliceVisual3D circle = new PieSliceVisual3D();
    circle.Center = center;
    circle.OuterRadius = rad;
    circle.InnerRadius = circle.OuterRadius + 3;
    circle.StartAngle = (Math.Atan2(linept.ElementAt(0).Y - center.Y, linept.ElementAt(0).X - center.X) * 180 / Math.PI);
    circle.EndAngle = (Math.Atan2(currentPoint.Y - center.Y, currentPoint.X - center.X) * 180 / Math.PI);

    //I've also tried these next 4 lines to no avail
    double startAngle = (Math.Atan2(linept.ElementAt(0).Y - center.Y, linept.ElementAt(0).X - center.X) * 180 / Math.PI);
    circle.StartAngle = (startAngle > 0.0 ? startAngle : (360.0 + startAngle));
    double endAngle = (Math.Atan2(currentPoint.Y - center.Y, currentPoint.X - center.X) * 180 / Math.PI);
    circle.EndAngle = (endAngle > 0.0 ? endAngle : (360.0 + endAngle));
}
4

0 回答 0