//-------------------------------------------------------------- void myAmeManager::saveCameraPosition() { posMat = cam.getTarget().getGlobalTransformMatrix(); ofxXmlSettings *XML = new ofxXmlSettings("GUI/otherSettings.xml"); XML->setValue("posMat_00", posMat(0,0), 0); XML->setValue("posMat_01", posMat(0,1), 0); XML->setValue("posMat_02", posMat(0,2), 0); XML->setValue("posMat_03", posMat(0,3), 0); XML->setValue("posMat_10", posMat(1,0), 0); XML->setValue("posMat_11", posMat(1,1), 0); XML->setValue("posMat_12", posMat(1,2), 0); XML->setValue("posMat_13", posMat(1,3), 0); XML->setValue("posMat_20", posMat(2,0), 0); XML->setValue("posMat_21", posMat(2,1), 0); XML->setValue("posMat_22", posMat(2,2), 0); XML->setValue("posMat_23", posMat(2,3), 0); XML->setValue("posMat_30", posMat(3,0), 0); XML->setValue("posMat_31", posMat(3,1), 0); XML->setValue("posMat_32", posMat(3,2), 0); XML->setValue("posMat_33", posMat(3,3), 0); XML->setValue("distance", cam.getDistance(), 0); XML->saveFile("GUI/otherSettings.xml"); delete XML; }
//-------------------------------------------------------------- void myAmeManager::loadCameraPosition() { message = "loading mySettings.xml"; if( XML.loadFile("GUI/otherSettings.xml") ){ message = "otherSettings.xml loaded!"; }else{ message = "unable to load mySettings.xml check data/ folder"; } posMat(0,0)= XML.getValue("posMat_00",0.0, 0); posMat(0,1)= XML.getValue("posMat_01",0.0, 0); posMat(0,2)= XML.getValue("posMat_02",0.0, 0); posMat(0,3)= XML.getValue("posMat_03",0.0, 0); posMat(1,0)= XML.getValue("posMat_10",0.0, 0); posMat(1,1)= XML.getValue("posMat_11",0.0, 0); posMat(1,2)= XML.getValue("posMat_12",0.0, 0); posMat(1,3)= XML.getValue("posMat_13",0.0, 0); posMat(2,0)= XML.getValue("posMat_20",0.0, 0); posMat(2,1)= XML.getValue("posMat_21",0.0, 0); posMat(2,2)= XML.getValue("posMat_22",0.0, 0); posMat(2,3)= XML.getValue("posMat_23",0.0, 0); posMat(3,0)= XML.getValue("posMat_30",0.0, 0); posMat(3,1)= XML.getValue("posMat_31",0.0, 0); posMat(3,2)= XML.getValue("posMat_32",0.0, 0); posMat(3,3)= XML.getValue("posMat_33",0.0, 0); cam.setDistance(XML.getValue("distance",0.0, 0)); cam.getTarget().setTransformMatrix(posMat); }
int main() { int i, j, k, l, len, nPerms, max; int *univ, **perm, **pos, **count; int *averg, *result1, *result2, *result3, *final; float avg=0, min; printf("\nEnter size of array: "); scanf("%d", &len); printf("\nEnter number of permutations to take: "); scanf("%d", &nPerms); // Memory allocation of arrays. { univ = (int *)malloc(len * sizeof(int)); averg = (int *)malloc(len * sizeof(int)); // sum array result1 = (int *)malloc(len * sizeof(int)); // result by mean result2 = (int *)malloc(len * sizeof(int)); // result by count result3 = (int *)calloc(len , sizeof(int)); // result by graph perm = (int **)malloc(nPerms * sizeof(int *)); // string matrix for (i = 0; i < nPerms; i++) perm[i] = (int *)malloc(len * sizeof(int)); pos = (int **)malloc(nPerms * sizeof(int *)); // positional matrix for (i = 0; i < nPerms; i++) pos[i] = (int *)malloc(len * sizeof(int)); count = (int **)calloc(len, sizeof(int *)); // count matrix for (i = 0; i < len; i++) count[i] = (int *)calloc(len, sizeof(int)); } // Generation of strings and their positional matrix and displaying them { randomAr(len, nPerms, perm); // Generating random strings. printf("\n"); for (i = 0; i < nPerms; i++) // Display the random strings { printf("Permutation array %d\t: ", i+1); display(perm[i], len); } for (i = 0; i < nPerms; i++) // Determinimg the positional matrix posMat(len, perm[i], pos[i]); // printf("\n"); // Display of positional matrix // for (i = 0; i < nPerms; i++) // { // printf("Positional array %d\t: ", i+1); // display(pos[i], len); // } } // mean calculation { printf("\n"); for (j = 0; j < len; j++) // Calculating mean { avg=0; for (i = 0; i < nPerms; i++) avg+= pos[i][j]; averg[j] = avg; // printf("%f - %f\n", avg, avg/nPerms); } } // printf("The result1ant array (result1) : "); finalMat(len, averg, result1); // result1 - result by mean // printf("\n"); // printf("The positional resultlant array : "); posMat(len, result1, univ); // Positional array of result1 // display(univ, len); // printf("\n"); avg=0; for (i = 0; i < nPerms; ++i) // Dist from the result1 avg+=dist(len, nPerms, pos[i], univ); avg/= (len*nPerms*len); avg*=2; // printf("%f", avg); min = avg; final = result1;