sectorAtPointer method
反算指针下的奖品;无奖品或非有限角度返回 −1。
Implementation
int sectorAtPointer(double rotateDeg, double offsetDegree) {
if (count == 0 || !rotateDeg.isFinite || !offsetDegree.isFinite) return -1;
var a = (-(rotateDeg + offsetDegree)).remainder(kLuckyFullTurnDeg);
if (a < 0) a += kLuckyFullTurnDeg;
for (var i = 0; i < count; i++) {
if (startDeg(i) <= a && a < startDeg(i) + sweepDeg(i)) return i;
}
// 累加误差可能使最后一个区间终点略小于 360。
return count - 1;
}