- double start = a->angle[0];
- double end = start + a->angle[1];
-
- // Swap 'em if the span is negative...
- if (a->angle[1] < 0)
- {
- end = a->angle[0];
- start = end + a->angle[1];
- }
-
- rect = Rect(Point(cos(start), sin(start)), Point(cos(end), sin(end)));
-
- // If the end of the arc is before the beginning, add 360 degrees to it
- if (end < start)
- end += TAU;
-
-/*
-Find which quadrant the start angle is in (consider the beginning of the 90° angle to be in the quadrant, the end to be in the next quadrant). Then, divide the span into 90° segments. The integer portion is the definite axis crossings; the remainder needs more scrutiny. There will be an additional axis crossing if the the sum of the start angle and the remainder is > 90°.
-*/
-#if 1
- int quadStart = (int)(a->angle[0] / QTR_TAU);
- double qsRemain = a->angle[0] - ((double)quadStart * QTR_TAU);
- int numAxes = (int)((a->angle[1] + qsRemain) / QTR_TAU);
-
- double axis[4] = { 0, 0, 0, 0 };
- axis[0] = rect.t, axis[1] = rect.l, axis[2] = rect.b, axis[3] = rect.r;
- double box[4] = { 1.0, -1.0, -1.0, 1.0 };
-
- for(int i=0; i<numAxes; i++)
- axis[(quadStart + i) % 4] = box[(quadStart + i) % 4];
-
- // The rect is constructed the same way we traverse the axes: TLBR
- Rect r2(axis[0], axis[1], axis[2], axis[3]);
-
- rect |= r2;
-#else
- // Adjust the bounds depending on which axes are crossed
- if ((start < QTR_TAU) && (end > QTR_TAU))
- rect.t = 1.0;
-
- if ((start < HALF_TAU) && (end > HALF_TAU))
- rect.l = -1.0;
-
- if ((start < THREE_QTR_TAU) && (end > THREE_QTR_TAU))
- rect.b = -1.0;
-
- if ((start < TAU) && (end > TAU))
- rect.r = 1.0;
-
- if ((start < (TAU + QTR_TAU)) && (end > (TAU + QTR_TAU)))
- rect.t = 1.0;
-
- if ((start < (TAU + HALF_TAU)) && (end > (TAU + HALF_TAU)))
- rect.l = -1.0;
-
- if ((start < (TAU + THREE_QTR_TAU)) && (end > (TAU + THREE_QTR_TAU)))
- rect.b = -1.0;
-#endif
-
- rect *= a->radius[0];
- rect.Translate(a->p[0]);