void ParticleSystem::update(float milliseconds, Camera &camera) { updateEmitters(milliseconds); updateParticles(milliseconds); const mat3 &cameraOrientation = camera.getOrientation(); mat4 modl(camera.getPosition(), cameraOrientation.getAxisX(), cameraOrientation.getAxisY(), cameraOrientation.getAxisZ()); updateParticleBatches(modl); }
//************************************************************************************** // Function name : CFrustum::CalculateFrustum // Author : Gary Ingram // Return type : void // Date Created : 25/05/2003 // Description : Calculates the frustum from the modelview and projection // matrices, The frustrum that is set in this class is a // static member and so will be the same wherever it is used //************************************************************************************** void CFrustum::CalculateFrustum() { CMatrix proj(GL_PROJECTION_MATRIX); CMatrix modl(GL_MODELVIEW_MATRIX); ////////////////////////////////////////////// //Now that we have our modelview and // //projection matrix, if we combine these 2 // //matrices, it will give us our clipping // //planes. To combine 2 matrices, we // //multiply them. // ////////////////////////////////////////////// CMatrix clip(proj*modl); ////////////////////////////////////////////// //Now we actually want to get the sides of // //the frustum. To do this we take the // //clipping planes we received above and // //extract the sides from them. // ////////////////////////////////////////////// ////////////////////////////////////////////// //This will extract the RIGHT side of the // //frustum // ////////////////////////////////////////////// m_Frustum[RIGHT][A] = clip.element( 3) - clip.element( 0); m_Frustum[RIGHT][B] = clip.element( 7) - clip.element( 4); m_Frustum[RIGHT][C] = clip.element(11) - clip.element( 8); m_Frustum[RIGHT][D] = clip.element(15) - clip.element(12); ////////////////////////////////////////////// //Now that we have a normal (A,B,C) and a // //distance (D) to the plane, we want to // //normalize that normal and distance. // ////////////////////////////////////////////// ////////////////////////////////////////////// //Normalize the RIGHT side // ////////////////////////////////////////////// NormalizePlane(RIGHT); ////////////////////////////////////////////// //This will extract the LEFT side of the // //frustum // ////////////////////////////////////////////// m_Frustum[LEFT][A] = clip.element( 3) + clip.element( 0); m_Frustum[LEFT][B] = clip.element( 7) + clip.element( 4); m_Frustum[LEFT][C] = clip.element(11) + clip.element( 8); m_Frustum[LEFT][D] = clip.element(15) + clip.element(12); ////////////////////////////////////////////// //Normalize the LEFT side // ////////////////////////////////////////////// NormalizePlane(LEFT); ////////////////////////////////////////////// //This will extract the BOTTOM side of the // //frustum // ////////////////////////////////////////////// m_Frustum[BOTTOM][A] = clip.element( 3) + clip.element( 1); m_Frustum[BOTTOM][B] = clip.element( 7) + clip.element( 5); m_Frustum[BOTTOM][C] = clip.element(11) + clip.element( 9); m_Frustum[BOTTOM][D] = clip.element(15) + clip.element(13); ////////////////////////////////////////////// //Normalize the BOTTOM side // ////////////////////////////////////////////// NormalizePlane(BOTTOM); ////////////////////////////////////////////// //This will extract the TOP side of the // //Frustum // ////////////////////////////////////////////// m_Frustum[TOP][A] = clip.element( 3) - clip.element( 1); m_Frustum[TOP][B] = clip.element( 7) - clip.element( 5); m_Frustum[TOP][C] = clip.element(11) - clip.element( 9); m_Frustum[TOP][D] = clip.element(15) - clip.element(13); ////////////////////////////////////////////// //Normalize the TOP side // ////////////////////////////////////////////// NormalizePlane(TOP); ////////////////////////////////////////////// //This will extract the BACK side of the // //frustum // ////////////////////////////////////////////// m_Frustum[BACK][A] = clip.element( 3) - clip.element( 2); m_Frustum[BACK][B] = clip.element( 7) - clip.element( 6); m_Frustum[BACK][C] = clip.element(11) - clip.element(10); m_Frustum[BACK][D] = clip.element(15) - clip.element(14); ////////////////////////////////////////////// //Normalize the BACK side // ////////////////////////////////////////////// NormalizePlane(BACK); ////////////////////////////////////////////// //This will extract the FRONT side of the // //frustum // ////////////////////////////////////////////// m_Frustum[FRONT][A] = clip.element( 3) + clip.element( 2); m_Frustum[FRONT][B] = clip.element( 7) + clip.element( 6); m_Frustum[FRONT][C] = clip.element(11) + clip.element(10); m_Frustum[FRONT][D] = clip.element(15) + clip.element(14); ////////////////////////////////////////////// //Normalize the FRONT side // ////////////////////////////////////////////// NormalizePlane(FRONT); }
int main(int argc, char * argv[]){ if (argc < 5){ help(); return -1; } char * input = NULL; char * arg = NULL; int n = 0; int i = 0; while (i < argc){ arg = argv[i]; if (0 == strcmp(arg, "-f")){ input = argv[++i]; } else if (0 == strcmp(arg, "-n")){ n = atoi(argv[++i]); } i += 1; } if (NULL == input){ fprintf(stderr,"no input data exit(-1)\n"); return -1; } FILE * f = NULL; if (NULL == (f = fopen(input,"r"))){ fprintf(stderr, "can not open input file \n"); return -1; } int * l = (int*)malloc(sizeof(int) * n); double * d = (double*)malloc(sizeof(double) * n); memset(l, 0, sizeof(int) * n); memset(d, 0, sizeof(double) * n); for (int i = 0; i < n; i++){ d[i] = (double)i; fscanf(f, "%d", l + i); } fclose(f); int nd = 0; double * LogD = initLogD(n << 1); double * sp = modl(d, l, LogD, n, &nd); if (nd < 1){ fprintf(stderr, "no split point\n"); goto free_malloc; } int * ol = (int*)d; memset(ol, 0, sizeof(int) * n); for (int i = 0; i <= nd; i++){ int b = 0, e = n, c = 0; if (i > 0) b = (int)sp[i - 1] + 1; if (i < nd) e = (int)sp[i] + 1; for (int j = b; j < e; j++) { c += l[j]; } if (c > e - b - c){ for (int j = b; j < e; j++){ ol[j] = 1; } } } free(sp); sp = NULL; for (int i = 0; i < n; i++){ printf("%d", ol[i]); } printf("\n"); free_malloc: free(LogD); LogD = NULL; free(d); d = NULL; free(l); l = NULL; return 0; }
int main(void) { largeInt l1, l2,l3,sum,diff,product; largeNum n1, n2,sumn; div_result divi; int x,prime_n1,prime_n2; printf("Enter 1st number:"); readint(&l1); printf("\n"); printf("Enter 2nd number:"); readint(&l2); printf("\nThe 1st number is :\n"); showI(l1); printf("\nThe 2nd number is :\n"); showI(l2); printf("\n"); // printf("chk_equal=%d",chk_equal(l1,l2)); // printf("\n"); // showI(increment1(l1)); // fwriteI(l3); // printf("\nequal zero: %d",equal_to_zero(n1)); // shift(&n1,3); // showN(n1); // shift(&n1,-2); // showN(n1); // printf("\nAfter removing all zeroes from left;"); // rem_all_zeros_from_left(&n1); // showN(n1); // x=equal_to_zero(l1); // printf("\n Value of x: %d\n",x); // x=greaterthan(l1,l2); // printf("\n Value of x: %d\n",x); sum=addl(l1,l2); // Addition.. printf("\n\nSum="); showI(sum); // sumn=add_n_times(n1,2); // printf("\nSUM_N="); // showN(sumn); diff=subl(l1,l2); printf("\n\nDifference="); showI(diff); product=multl(l1,l2); printf("\n\nproduct="); showI(product); printf("\n\n"); // append_n_zeros_right(&n1,2); // showN(n1); // remove_one_zero_right(&n1); // printf("\n"); // showN(n1); divi=divl(l1,l2); showDiv(divi); printf("\nmodulus of 1st and 2nd number:"); showI(modl(l1,l2)); x=Isprime(l1); if(x==1) printf("\nPRIME"); else printf("\nNOT PRIME\n"); return 0; }