We have set of intervals [theta,-theta] . I want to find out the optimal value of theta [-180,180] which lies in the maximum no of intervals . Value of theta can be float . Can you please help me find the way to find out the optimal theta.
№ | Пользователь | Рейтинг |
---|---|---|
1 | jiangly | 3640 |
2 | Benq | 3593 |
3 | tourist | 3572 |
4 | orzdevinwang | 3561 |
5 | cnnfls_csy | 3539 |
6 | ecnerwala | 3534 |
7 | Radewoosh | 3532 |
8 | gyh20 | 3447 |
9 | Rebelz | 3409 |
10 | Geothermal | 3408 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | maomao90 | 173 |
2 | adamant | 164 |
3 | awoo | 161 |
4 | TheScrasse | 160 |
5 | nor | 159 |
6 | maroonrk | 156 |
7 | SecondThread | 152 |
8 | pajenegod | 146 |
9 | BledDest | 144 |
10 | Um_nik | 143 |
We have set of intervals [theta,-theta] . I want to find out the optimal value of theta [-180,180] which lies in the maximum no of intervals . Value of theta can be float . Can you please help me find the way to find out the optimal theta.
Название |
---|
Auto comment: topic has been updated by selfcompiler (previous revision, new revision, compare).
Got the Answer
Sort the interval start and end values into a single list with a corresponding value for 'S' or 'E' for each one.
Scan the list, when you hit an S increment a counter, when you hit an E decrement a counter. If the counter is higher than the highest value seen so far remember the S and E values for that segment.
For the wrap-around case, simply split each interval that wraps (i.e. angle2 < angle1) into two pieces, one either side of zero. Add [angle1,360] and [0,angle2] as new intervals into the starting set.