writing multiple points into a vector field

heya. i’m trying to create a vector field from the movement of centroids.

using the centroid of one blob, i can easily change the vector field. but as soon as i try to do multiple points, shit goes haywire.

i’ve been cramming together a number of files i’ve found along the way, most notable these : The vector-&-vectorfield-examples from the ofAmsterdam-workshop and Theo’s blob-persistence-tracking.

The first snippet works just fine :

	for (int i = 0; i < contourFinder.nBlobs; i++){  
		currentPos.set((3.2*contourFinder.blobs[0].centroid.x)/ofGetWidth(), (3.2*contourFinder.blobs[0].centroid.y)/ofGetHeight());  
	ofxVec2f motionVector = (currentPos-prevPos)*3;	  
	vecField.addIntoField(currentPos.x, currentPos.y, motionVector, 0.3);  
	prevPos = currentPos;  

this second one does not though. it pins the object i want to move around in the 0,0 position, and draws no field

	for(int i = 0; i < trackedBlobs.size(); i++){  
		currentPos[i].set((3.2*trackedBlobs[i].centroid.x)/ofGetWidth(), (3.2*trackedBlobs[i].centroid.y)/ofGetHeight());  
	for(int i = 0; i < trackedBlobs.size(); i++){  
		motionVector[i] = (currentPos[i]-prevPos[i])*3;	  
		vecField.addIntoField(currentPos[i].x, currentPos[i].y, motionVector[i], 0.3);  
		prevPos[i] = currentPos[i];  

any ideas why the second instance wouldn’t draw into a field?

EDIT : here-is-the-src, needs ofxOpenCV and ofxVectormath addons

my immediate guess is that you’re invisibly using an integer somewhere, so that your screen percentage values (blahblah.x / ofGetWidth()) get truncated to 0, effectively thrown away. but hard to tell as-is.

printf is your friend. print out all your currentPos[] values to be sure they are what you think they should be. print out your motionVector[] values as well. this should give you some insight into what’s going on.