in reply to Problems processing data for graph

Range -180 .. 180 transformed into 0 .. 360 smells like angles. If this is the case, simply adding 180 will invert your phase, so you'd probably better do something like:
# Add a complete round angle, i.e. 360 degrees $angle += 360 if ($angle < 0);
unless you actually want to invert phase. Or unless they're not angles :)

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.

Replies are listed 'Best First'.
Re^2: Problems processing data for graph
by tlm (Prior) on May 04, 2005 at 14:23 UTC

    In this case adding 180 amounts to the first part of the standard binning transformation of subtracting the minimum value, and dividing by the bin size. In fact the OP's two routines ConvertToFromZero and BinAngles just spread this transformation over two subroutines.

    the lowliest monk

      Oh, I now see they're angles indeed. What I want to point out is that the OP is doing a 180 degrees translation, while he could mean to evaluate the Principal Argument, in which case should use the transformation I propose above.

      Of course, if the problem is only that of binning, for example to produce some graphics, it all reduces to choosing the correct x-axis; OTOH, if the OP wants to use these angles for some evaluations (e.g. sin, cos, stability of a system, whatever) he'd better use the correct angle wrapping function.

      Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

      Don't fool yourself.
        Thanks, that's good to know :)