Sunday, May 14, 2006

pidgin code snippet for keeping two changing values apart

Here is a pidgin code snippet I wrote useful for keeping two constantly changing values from getting to close to each other. Brings to mind things like keeping two airplanes away from each other.

initialization

blah=docval/2
//docval shows user input limit of closeness of gb and gt when gb, gt changing

Program segment

indik=mathAbs(gt=gb)/2
duk=mathAbs(blah-indik);
if(indik<blah)&&(gt<gb)
{gtduplicate=gt;gbduplicate=gb;gt=gt-duk;gb=gb+duk}
if(indik<blah)&&(gt>=gb)
{gtduplicate=gt;gbduplicate=gb;gt=gt+duk;gb=gb-duk}

//gt and gb values are now used for some thing

gt=gtduplicate
gb=gbduplicate
/*here after use the two object values are returned to what they would have been except for the exception resulting from desire to keep a distance between the two objects;
then again it might be interesting to let the veering away from each other also change the subsequent number positions of the two objects
*/

0 Comments:

Post a Comment

<< Home

SM
GA
SC