theory question, constrain()

I want to set limits for the motion of my quadruped robot legs such that:

-----when I select an individual foot to control with joysticks changing the values of x,y,z of the foot (x + xchange, y + ychange etc.,,,, map(xJoystick, 0, 1023, -4, 4) ((millimeters)) ,,, --- ,,, (push joystick 1 to left, x coordinate of selected foot begins moving so many millimeters per loop, etc. using kinematics engine).

-----when the foot reaches the edge of its possible reach, rather than the x coordinate continuing to change within the loop (able to reach coordinates of thousands of millimeters away in seconds, viewable on serial monitor), the x coordinate will remain set at the constraint at the edge of the foots work envelope.

------so,, costraint will NOT be simply an x coordinate relative to the robots body center (0,0 on the coordinate field in my kinematics engine present),, the constraint will need to be set to a spherical circumference around the hip joint. (well,, I realize that in truth my leg will have lots of limitations based on the joints of my leg,, and that it is a VERY complex series of relatively simple equations,, I will for now be happy with a simple circle constraint that ensures that when I send my joystick back the other direction, I don't have to wait and wait for x to enter back within my general field of motion)))))....

SO,, does constraint work this way?? where I can program ---constrain(x, center of circle, circumference of circle),, ,,

No but an if statement would. If the distance from the foot to the center point is larger than some value. You just have to calculate the distance.