Make sure that pull doesn't accidentally do a reverse pull

Started by gringer

gringer Lv 1

When I'm doing a pull, I sometimes isolate off some segments of a loop (say 5-8 segments), then try to shift one piece of the loop in one direction. Sometimes, the piece moves in the direction completely opposite from the direction I want, no matter how hard I pull (i.e. no matter how long the pull arrow is). This is frustrating, particularly when I want to do a little tweak, and it makes the rest of the loop go all wonky.

How about before actually updating the protein after doing a pull, the program checks to see if the thing pulled is actually closer to the target, e.g.:

(X1,Y1,Z1): location of pull origin
(X2,Y2,Z2): location of pull target

oldState = saveState();
distanceBefore = sqrt((X1-X2)^2,(Y1-Y2)^2,(Z1-Z2)^2);
doPull((X1,Y1,Z1),(X2,Y2,Z2));
distanceAfter = sqrt((X1-X2)^2,(Y1-Y2)^2,(Z1-Z2)^2);
if(distanceAfter < distanceBefore){
message("Unable to pull in that direction");
loadState(oldState);
}