seia0106 wrote:

Hello John,

Thank you for the reply and tip.

If it is possible for your can you please explain a little how the use

of fmod() is changing the ranging from -pi to +pi to '0 to 2pi' now?

fmod isn't changing the range.

Look at the first argument given to fmod. There a constant

of 2*pi is added to the number. The result of atan2 can only

be in the range -pi to +pi. So adding 2*pi gives a range

of pi to 3*pi (note that now the boundary of this range

are both positive) and fmod is used to clamp that down

to [0 to 2*pi[, by taking the remainder of the division with

2*pi.

It really is the same as using % on integer

0 % 5 -> 0

1 % 5 -> 1

2 % 5 -> 2

3 % 5 -> 3

4 % 5 -> 4

5 % 5 -> 0

6 % 5 -> 1

7 % 5 -> 2

8 % 5 -> 3

9 % 5 -> 4

10 % 5 -> 0

11 % 5 -> 1

...

Here the division by 5 leaves us with a remainder which by nature is

always in the range 0 to 4. (If you have 23 apples and 5 kids and you

give each kid an equal amount of apples, how many apples are left. The

answer cannot be greater then 4, because of it were 5 or above, each kid

would get an additional apple, which eventually would bring down the number

of apples left to less then 5)

--

Karl Heinz Buchegger

kb******@gascad.at