Q: Feature Wish: "%" Extension

Jive Dadson jdadson at ix.netcom.com
Sun Nov 4 21:41:41 EST 2001


I work in robotics.  Our robots have several rotary axes, each of which
can turn considerably more than 360 degrees.  The positions 5 degrees
and 365 degress are not equivalent, because the arms can contain wires
and tubes that can only be twisted so many times.  I am continually
using the following function, often to "mod out" multiples of 360
degrees.

// "Floating point modulus" function
inline double fpMod(double x, double modulus) {
    return  x-floor(x/modulus)*modulus;
}



More information about the Python-list mailing list