Your output value should be an absolute angle, not a relative one.

It's because of this that the business with "turns = floor(...)" is
necessary.  Imagine that you re always cutting the pattern in a
counterclockwise direction -- the blade will continue turning in one
direction, and its angle number will get larger and larger, eventually
being greater than 360 degrees (or 2*PI radians, since all the standard
math functions work in radians).

The floor() function returns the integer part of a number, rounded down.
So floor(1.0) is 1.0, floor(0.5) is 0.0, and floor(-0.5) is -1.0.  Thus,
turns gets the number of entire revolutions the blade has performed.
Then, that number of revolutions is added back to the angle computed by
atan2() (which is always in the range of -pi to +pi), and finally
figures out whether the resulting angle, or the angle with one turn more
or less, is closer to the current angle.

Jeff

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to