internal void DrawEllipticalArc(double cx, double cy, double a, double b,
double theta, double lambda1, double lambda2,
bool isPieSlice)
{
this.cx = cx;
this.cy = cy;
this.a = a;
this.b = b;
this.theta = theta;
this.isPieSlice = isPieSlice;
// Angles in radians
lambda1 = lambda1 * Math.PI / 180;
lambda2 = lambda2 * Math.PI / 180;
// Handle negative sweep angles
if (lambda2 < 0)
{
var temp = lambda1;
lambda1 += lambda2;
lambda2 = temp;
}
else
lambda2 += lambda1;
eta1 = Math.Atan2(Math.Sin(lambda1) / b,
Math.Cos(lambda1) / a);
eta2 = Math.Atan2(Math.Sin(lambda2) / b,
Math.Cos(lambda2) / a);
cosTheta = Math.Cos(theta);
sinTheta = Math.Sin(theta);
// make sure we have eta1 <= eta2 <= eta1 + 2 PI
eta2 -= twoPi * Math.Floor((eta2 - eta1) / twoPi);
// the preceding correction fails if we have exactly et2 - eta1 = 2 PI
// it reduces the interval to zero length
if ((lambda2 - lambda1 > Math.PI) && (eta2 - eta1 < Math.PI))
{
eta2 += 2 * Math.PI;
}
computeFocii();
// NOTE: Max degrees handled by the routine is 3
drawEllipticalArcToContext(3, 0);
}