Hi,
I made you a little example of repulsion. To make it quick, I used the mouse pointor as repulsion center. You can do the same thing with the blob centroid instead of the mouse coordinates.
ofVec2f p; // Coordinate of the object to move
void ofApp::update()
{
ofVec2f c( ofGetMouseX(), ofGetMouseY() ); // Point of repulsion
ofVec2f v = p - c; // Vector between c and p
float d = v.length(); // Distance between c and p
float f = 10000 / d / d; // Intensity of the repulsion (quick search on the web, found http://www.physicsclassroom.com/class/estatics/Lesson-3/Coulomb-s-Law)
v = v.getNormalized() * f; // Force vector
p += v; // Move the point with this vector
// Just to bound the movement
p.x = ofClamp( p.x, 50, ofGetWidth() - 50 );
p.y = ofClamp( p.y, 50, ofGetHeight() - 50 );
}
void ofApp::draw()
{
ofCircle( p.x, p.y, 30 );
}
src.zip (1.4 KB)
@fbrmz has already replied the same think to you. Perhaps you haven't understood (don't know, you did not answer), that's why I wrote an example.