This project has moved. For the latest updates, please go here.

Bug found in Arc toPolyline

Nov 7, 2013 at 5:28 PM

I had some data that wrapped around beyond zero, which caused the conversion to polyline to flip the direction of the arc.

I changed the PolygonalVertexes code to this and it seemed to fix it. It sould probably do with being improved and validated a bit more (eg for if the arc is CCW instead of CW) but I thought I would let the community know

double start = arc.StartAngle*MathHelper.DegToRad;
            if (arc.EndAngle< arc.StartAngle)
                arc.EndAngle = arc.EndAngle + 360;


            double end = arc.EndAngle*MathHelper.DegToRad;

            double angle = (end - start)/precision;

Nov 14, 2013 at 3:47 PM
Thanks for posting, Robert_Smart!

I noticed the exact same problem (And used the exact same fix) for Elllipse toPolyline. This definitely needs attention!
Nov 14, 2013 at 7:03 PM
Yes, both Arc.ToPolyne and Ellipse.ToPolyline share the same problem. Also I will add code to normalize any angle value to the range between 0 to 360 degrees, to avoid further problems.

Your fix will work as long as the angle values are in that range, I would not change the original arc.EndAngle value and use instead this code in the PolygonalVertexes method.
double start = this.startAngle*MathHelper.DegToRad;
double end = this.endAngle*MathHelper.DegToRad;
if (end < start)
    end += MathHelper.TwoPI;
double angle = (end - start)/precision;