Write a function that takes 2 arguments: Arg 1: Radians (a value between 0 and 2*PI)
Arg 2: Sectors (an integer between 2 and 32)
Signature: (defun GetSector ( radians sectors )
...
)
Objective: Find where the value
radians falls in a circle divided into
sectors.
If the radians value corresponds exactly to a sector boundary return the whole
number that is equal to the lower sector it is adjacent to.
For any radian value that does not correspond to a sector boundary, return
the whole number that is equal to the lower sector it is adjacent to
plus 0.5.
Sector numbers start at
1.
For example, given radian values of: pi/8
pi/6
pi/4
pi/2
pi
And a sectors value of 4 ( boundaries on multiples of pi/2, or 90° )
the return values should be: 0.5
0.5
0.5
1.0
2.0
Using the same radian values but a sectors value of 5 ( boundaries on multiples of 2pi/5 or 72° )
the return values should be: 0.5
0.5
0.5
1.5
2.5
Using the same radian values but a sectors value of 6 ( boundaries on multiples of pi/3 or 60° )
the return values should be: 0.5
0.5
0.5
1.5
3.0
Perhaps an illustration of the
first example will make it easier to understand than my pigeon engrish:
![](http://www.theswamp.org/screens/mp/sectors.png)
A radians value of precisely 0 should return 0.
A radians value of precisely pi/2 should return 1.
Radians values between 0 and pi/2 should return 0.5.
Clear as mud?
![Cheesy :D](http://www.theswamp.org/Smileys/black/cheesy.gif)
Even someone with say a grossly verbose vertical coding style should be able to do it in a half dozen lines of code. :whistle:
Note: Assume the function will be passed valid data, i.e. you do not have to qualify the arguments -- just do the math.