Блог пользователя selfcompiler

Автор selfcompiler, история, 8 лет назад, По-английски

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.

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by selfcompiler (previous revision, new revision, compare).

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.