diff jnmr/DynamicVector.cpp @ 44:6c8a048720c3

improving functions in dynamic vector - to copy with changing offset in copyvector and the drawvector routine
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Wed, 01 Feb 2012 16:07:09 +0000
parents fa527df85c2c
children 43edc8abe2a7
line wrap: on
line diff
--- a/jnmr/DynamicVector.cpp	Tue Jan 24 17:11:11 2012 +0000
+++ b/jnmr/DynamicVector.cpp	Wed Feb 01 16:07:09 2012 +0000
@@ -30,6 +30,7 @@
 
 void DynamicVector::copyFromDynamicVector(const DynamicVector& dynamicVec){
 	if (dynamicVec.length == length){
+		offset = dynamicVec.offset;
 		for (int i = 0;i < length;i++)
 			array[i] = dynamicVec.array[i];
 	}
@@ -172,6 +173,25 @@
 //	addGaussianShapeByLookupTable(mean, StdDev, factor);
 }
 
+
+void DynamicVector::addGaussianShapeFromRealTime(const double& actualTime, const double& StdDev, double factor){
+	
+	double mean = getRealTermsAsIndex(actualTime);
+	printf("Gaussian realtime %f at index %f\n", actualTime, mean);
+	int i;
+	double std_dev_factor = (2*StdDev*StdDev);
+	factor *= (1/(StdDev*sqrt(2*PI)));
+	int maxVal = min((int) array.size(), (int)(mean + 4.8*StdDev));
+	int minVal = max(0, (int)(mean - 4.8*StdDev));
+	
+	for (i=minVal;i < maxVal;i++){
+		array[i] += factor*exp(-1*(i-mean)*(i-mean)/(std_dev_factor));
+	}
+	
+	//	addGaussianShapeByLookupTable(mean, StdDev, factor);
+}
+
+
 void DynamicVector::addGaussianShapeByLookupTable(double& mean, double& StdDev, double factor){
 	int i;
 	int lookupIndex ;
@@ -257,7 +277,8 @@
 		int newHeightPixel;
 		for (int i = startInt;i < endInt;i++){
 			newHeightPixel = (int) heightConstant * (maxVal - array[i]);
-			ofLine (stepSize*(i-1), lastHeightPixel, stepSize*i, newHeightPixel);
+			int xPos = i - startInt;
+			ofLine (stepSize*(xPos-1), lastHeightPixel, stepSize*xPos, newHeightPixel);
 			lastHeightPixel = newHeightPixel;
 		}