static void activate(void) { rotate_index = 0; rotate_timeout = ROTATE_INTERVAL; input_timeout = 0; ticks_countup = 0; create_text_splat(kl("game_over"), TLARGE, 0, &title_rotate[0]); create_text_splat(kl("press_esc"), TLARGE, 0, &title_rotate[1]); create_text_splat(kl("score_elapsed_time"), TSMALL, 0, &elapsed_time); create_text_splat(kl("score_achievements"), TMED, 0, &achievements); create_text_splat(kl("score_achievements_more"), TSMALL, 0, &achievements_more); create_text_splat(kl("score_achievements_none"), TSMALL, REFERENCE_WIDTH - 64, &achievements_none); achievement_count = 0; achievement_index = -1; for (size_t i = 0; i < bp__last; ++i) { if (game.score.bprops[i] && !score_lifetime.bprops[i]) { achieved_now[i] = true; ++achievement_count; if (achievement_index == -1) achievement_index = (int) i; char key[64]; snprintf(key, 64, "%s_title", score_bkeys[i]); create_text_splat(kl(key), TSMALL, REFERENCE_WIDTH - 48 - 4, &ach_title[i]); snprintf(key, 64, "%s_desc", score_bkeys[i]); create_text_splat(kl(key), TXSMALL, REFERENCE_WIDTH - 8, &ach_desc[i]); } else { achieved_now[i] = false; } } score_consolidate(); }
//----------------------------------------------------------------------------- SLLight::SLLight(SLfloat ambiPower, SLfloat diffPower, SLfloat specPower, SLint id) { // Set parameter of SLLight _id = id; _on = true; _spotCutoff = 180.0f; _spotCosCut = cos(SL_DEG2RAD*_spotCutoff); _spotExponent = 1.0f; // Set parameters of inherited SLMaterial _ambient.set (ambiPower, ambiPower, ambiPower); _diffuse.set (diffPower, diffPower, diffPower); _specular.set(specPower, specPower, specPower); // By default there is no attenuation set. This is physically not correct // Default OpenGL: kc=1, kl=0, kq=0 // Physically correct: kc=0, kl=0, kq=1 // set quadratic attenuation with d = distance to light // 1 // attenuation = ------------------ // kc + kl*d + kq*d*d kc(1.0f); kl(0.0f); kq(0.0f); }
const Matrix& TwoNodeLink::getTangentStiff() { // zero the matrix theMatrix->Zero(); // get resisting forces and stiffnesses Matrix kb(numDir,numDir); for (int i=0; i<numDir; i++) { qb(i) = theMaterials[i]->getStress(); kb(i,i) = theMaterials[i]->getTangent(); } // transform from basic to local system Matrix kl(numDOF,numDOF); kl.addMatrixTripleProduct(0.0, Tlb, kb, 1.0); // add geometric stiffness to local stiffness if (Mratio.Size() == 4) this->addPDeltaStiff(kl); // transform from local to global system theMatrix->addMatrixTripleProduct(0.0, Tgl, kl, 1.0); //Matrix kg(numDOF,numDOF); //kg.addMatrixTripleProduct(0.0, Tgl, kl, 1.0); //theMatrix->addMatrixTranspose(0.5, kg, 0.5); return *theMatrix; }
void activate(void) { create_text_splat(kl("title_1"), 18, 0, &title_1); create_text_splat(kl("title_2"), 24, 0, &title_2); create_text_splat(kl("byline"), 8, 0, &rotator[0]); create_text_splat(kl("ludum"), 8, 0, &rotator[1]); create_text_splat(kl("any_key"), 8, 0, &rotator[2]); rotate_index = 0; rotate_timeout = ROTATE_INTERVAL; event_add_handler(&any_key_handler, on_any_key, SDL_KEYUP); input_timeout = INPUT_SUPPRESS; backlight = sprite_thing_get(building_window_backlight); foreground = sprite_thing_get(building_window_fg); bottom = sprite_thing_get(building_fullwidth); dude.type = dude_stand; walking = false; action_interval = 0; position = -24; }
//------------------------------------------------------------------------ // install standard operators // for convenction on constant mapping of kstring/functors_operators // the call order MUST follow that of Operator::tag as declared // in operator.h // void AddStdOpers(OperTable *tbl) { tbl->Add(kstring(":-"), 255, Operator::XFX, Operator::RULE); tbl->Add(kstring("?-"), 255, Operator::FX, Operator::QUERY); tbl->Add(kstring(";"), 254, Operator::XFY, Operator::OR); tbl->Add(kstring(","), 253, Operator::XFY, Operator::AND); tbl->Add(kstring("spy"), 240, Operator::FX, Operator::SPY); tbl->Add(kstring("nospy"), 240, Operator::FX, Operator::NOSPY); tbl->Add(kstring("not"), 60, Operator::FX, Operator::NOT); tbl->Add(kstring("is"), 40, Operator::XFX, Operator::IS); tbl->Add(kstring(":="), 40, Operator::XFX, Operator::ASS); tbl->Add(kstring("=.."), 40, Operator::XFX, Operator::UNIV); tbl->Add(kstring("="), 40, Operator::XFX, Operator::EQ); tbl->Add(kstring("\\="), 40, Operator::XFX, Operator::NE); tbl->Add(kstring("<"), 40, Operator::XFX, Operator::LT); tbl->Add(kstring("=<"), 40, Operator::XFX, Operator::LE); tbl->Add(kstring(">="), 40, Operator::XFX, Operator::GE); tbl->Add(kstring(">"), 40, Operator::XFX, Operator::GT); tbl->Add(kstring("=="), 40, Operator::XFX, Operator::STRICTEQ); tbl->Add(kstring("\\=="), 40, Operator::XFX, Operator::STRICTNE); tbl->Add(kstring("-"), 31, Operator::YFX, Operator::SUB); tbl->Add(kstring("+"), 31, Operator::YFX, Operator::ADD); tbl->Add(kstring("/"), 21, Operator::YFX, Operator::DIV); tbl->Add(kstring("*"), 21, Operator::YFX, Operator::MUL); tbl->Add(kstring("mod"), 11, Operator::XFX, Operator::MOD); tbl->Add(kstring("^"), 10, Operator::XFY, Operator::POT); tbl->Add(kstring("\\"), 50, Operator::XFY, Operator::PATHNAME); tbl->Add(kstring(":-", 1), 255, Operator::FX, Operator::RULEUNARY); tbl->Add(kstring("-", 1), 31, Operator::FX, Operator::SUBUNARY); tbl->Add(kstring("+", 1), 31, Operator::FX, Operator::ADDUNARY); tbl->Add(kstring(":{", 1), 31, Operator::XF, Operator::I_BEGIN); tbl->Add(kstring(":}", 1), 31, Operator::XF, Operator::I_END); tbl->Add(kstring(":<", 1), 31, Operator::FX, Operator::I_INHERIT); tbl->Add(kstring(":/", 1), 31, Operator::FX, Operator::I_IMPORT); tbl->Add(kstring(":\\", 1), 31, Operator::FX, Operator::I_EXPORT); tbl->Add(kstring(":+", 1), 31, Operator::FX, Operator::I_DYNAMIC); tbl->Add(kstring(":$", 1), 31, Operator::FX, Operator::I_HANDLER); tbl->Add(kstring(":@", 1), 31, Operator::XFX, Operator::I_CREATE); tbl->Add(kstring(":", 1), 241, Operator::XFX, Operator::I_CALL); tbl->Add(kstring(":*", 1), 241, Operator::XFX, Operator::I_GCALL); tbl->Add(kstring(":~", 1), 31, Operator::FX, Operator::I_DESTROY); tbl->Add(kstring(":^", 1), 31, Operator::XFX, Operator::I_PROPLIST); tbl->Add(kstring(":&", 1), 31, Operator::XFX, Operator::I_ISA); kstring kl("."), kc("!"); }
int main(int argc, char** argv){ int i,j, *NNs; double **x,**q, bbtime, brutetime,*dToNNs,divTemp; treenode *root; struct timeval tvB,tvE; printf("**** bbtree **** \n"); processArgs(argc,argv); x = calloc(n,sizeof(double*)); q = calloc(m,sizeof(double*)); for(i=0;i<n;i++) x[i]=calloc(d,sizeof(double)); for(i=0;i<m;i++) q[i]=calloc(d,sizeof(double)); dToNNs = calloc(k,sizeof(double)); NNs = calloc(k,sizeof(int)); readData(x,n,d,datafile); readData(q,m,d,queryfile); bregdiv div; switch(divChoice){ case USEL2: div = l2squared(); printf("divergence = l_2^2\n"); break; case USEKL: div = kl(); printf("divergence = KL\n"); break; case USEKLD: div = dkl(); printf("divergence = conjugate to KL\n"); printf("WARNING: this has not been tested thoroughly\n"); break; case USEIS: div = is(); printf("divergence = Itakura-Saito\n"); printf("WARNING: this has not been tested thoroughly\n"); break; } printf("building.....\n"); gettimeofday(&tvB,NULL); root = buildTree(x,n,d,div,bucketSize); gettimeofday(&tvE,NULL); printf("done... build time: %6.2f \n",timediff(tvB,tvE)); gettimeofday(&tvB,NULL); multisearch(root,q,x,div,n,d,m,eps,k,INT_MAX); gettimeofday(&tvE,NULL); bbtime = timediff(tvB,tvE); printf("BBTREE time elapsed = %6.3f \n",bbtime); //Example of how to save & retrieve a bbtree: /*writeTree(root,d,"treefile.txt"); deleteTree(root); root = readTree("treefile.txt"); gettimeofday(&tvB,NULL); multisearch(root,q,x,div,n,d,m,eps,0,1); gettimeofday(&tvE,NULL); bbtime = timediff(tvB,tvE); printf("BBTREE time elapsed = %6.3f \n",bbtime); */ //brute force double curmin; int curBest; gettimeofday(&tvB,NULL); for(i=0;i<m;i++){ for(j=0;j<k;j++){ dToNNs[j]=HUGE_VAL; NNs[j]=-1; } curmin=HUGE_VAL; curBest=-1; for(j=0;j<n;j++){ divTemp = div.div(x[j],q[i],d); if(NNs[0]==-1 || divTemp < dToNNs[0]){ insert(NNs,dToNNs,j,divTemp,k); } } /* printf("query %d nns are \n",i); for(j=0;j<k;j++) printf("%d ",NNs[j]); printf("\n"); */ } gettimeofday(&tvE,NULL); brutetime = timediff(tvB,tvE); printf("BRUTE time elapsed = %6.3f \n",brutetime); if(isOutfile){ writeDoubs(2,outfile,bbtime,brutetime); } for(i=0;i<n;i++) free(x[i]); for(i=0;i<m;i++) free(q[i]); free(x); free(q); free(NNs); free(dToNNs); deleteTree(root); return 0; }
void ElasticTimoshenkoBeam2d::setUp() { // element projection static Vector dx(2); const Vector &ndICoords = theNodes[0]->getCrds(); const Vector &ndJCoords = theNodes[1]->getCrds(); dx = ndJCoords - ndICoords; //if (nodeIInitialDisp != 0) { // dx(0) -= nodeIInitialDisp[0]; // dx(1) -= nodeIInitialDisp[1]; //} //if (nodeJInitialDisp != 0) { // dx(0) += nodeJInitialDisp[0]; // dx(1) += nodeJInitialDisp[1]; //} //if (nodeJOffset != 0) { // dx(0) += nodeJOffset[0]; // dx(1) += nodeJOffset[1]; //} //if (nodeIOffset != 0) { // dx(0) -= nodeIOffset[0]; // dx(1) -= nodeIOffset[1]; //} // determine the element length L = dx.Norm(); if (L == 0.0) { opserr << "ElasticTimoshenkoBeam2d::setUp() - " << "element: " << this->getTag() << " has zero length.\n"; return; } // create transformation matrix from global to local system Tgl.Zero(); Tgl(0,0) = Tgl(1,1) = Tgl(3,3) = Tgl(4,4) = dx(0)/L; Tgl(0,1) = Tgl(3,4) = dx(1)/L; Tgl(1,0) = Tgl(4,3) = -dx(1)/L; Tgl(2,2) = Tgl(5,5) = 1.0; // determine ratio of bending to shear stiffness phi = 12.0*E*Iz/(L*L*G*Avy); // compute initial stiffness matrix in local system kl.Zero(); kl(0,0) = kl(3,3) = E*A/L; kl(0,3) = kl(3,0) = -kl(0,0); double a1z = E*Iz/(1.0 + phi); kl(1,1) = kl(4,4) = 12.0*a1z/(L*L*L); kl(1,4) = kl(4,1) = -kl(1,1); kl(2,2) = kl(5,5) = (4.0 + phi)*a1z/L; kl(2,5) = kl(5,2) = (2.0 - phi)*a1z/L; kl(1,2) = kl(2,1) = kl(1,5) = kl(5,1) = 6.0*a1z/(L*L); kl(2,4) = kl(4,2) = kl(4,5) = kl(5,4) = -kl(1,2); // compute geometric stiffness matrix in local system klgeo.Zero(); if (nlGeo == 1) { double b1z = 1.0/(30.0*L*pow(1.0 + phi,2)); klgeo(1,1) = klgeo(4,4) = b1z*(30.0*phi*phi + 60.0*phi + 36.0); klgeo(1,4) = klgeo(4,1) = -klgeo(1,1); klgeo(2,2) = klgeo(5,5) = b1z*L*L*(2.5*phi*phi + 5.0*phi + 4.0); klgeo(2,5) = klgeo(5,2) = -b1z*L*L*(2.5*phi*phi + 5.0*phi + 1.0); klgeo(1,2) = klgeo(2,1) = klgeo(1,5) = klgeo(5,1) = 3.0*L; klgeo(2,4) = klgeo(4,2) = klgeo(4,5) = klgeo(5,4) = -klgeo(1,2); } // compute initial stiffness matrix in global system Ki.addMatrixTripleProduct(0.0, Tgl, kl, 1.0); // compute mass matrix in global system M.Zero(); if (rho > 0.0) { if (cMass == 0) { // lumped mass matrix double m = 0.5*rho*L; for (int i=0; i<2; i++) { M(i,i) = m; M(i+3,i+3) = m; } } else { // consistent mass matrix Matrix mlTrn(6,6), mlRot(6,6), ml(6,6); mlTrn.Zero(); mlRot.Zero(); ml.Zero(); double c1x = rho*L/210.0; mlTrn(0,0) = mlTrn(3,3) = c1x*70.0; mlTrn(0,3) = mlTrn(3,0) = c1x*35.0; double c1z = c1x/pow(1.0 + phi,2); mlTrn(1,1) = mlTrn(4,4) = c1z*(70.0*phi*phi + 147.0*phi + 78.0); mlTrn(1,4) = mlTrn(4,1) = c1z*(35.0*phi*phi + 63.0*phi + 27.0); mlTrn(2,2) = mlTrn(5,5) = c1z*L*L/4.0*(7.0*phi*phi + 14.0*phi + 8.0); mlTrn(2,5) = mlTrn(5,2) = -c1z*L*L/4.0*(7.0*phi*phi + 14.0*phi + 6.0); mlTrn(1,2) = mlTrn(2,1) = c1z*L/4.0*(35.0*phi*phi + 77.0*phi + 44.0); mlTrn(4,5) = mlTrn(5,4) = -mlTrn(1,2); mlTrn(1,5) = mlTrn(5,1) = -c1z*L/4.0*(35.0*phi*phi + 63.0*phi + 26.0); mlTrn(2,4) = mlTrn(4,2) = -mlTrn(1,5); double c2z = rho/A*Iz/(30.0*L*pow(1.0 + phi,2)); mlRot(1,1) = mlRot(4,4) = c2z*36.0; mlRot(1,4) = mlRot(4,1) = -mlRot(1,1); mlRot(2,2) = mlRot(5,5) = c2z*L*L*(10.0*phi*phi + 5.0*phi + 4.0); mlRot(2,5) = mlRot(5,2) = c2z*L*L*(5.0*phi*phi - 5.0*phi - 1.0); mlRot(1,2) = mlRot(2,1) = mlRot(1,5) = mlRot(5,1) = -c2z*L*(15.0*phi - 3.0); mlRot(2,4) = mlRot(4,2) = mlRot(4,5) = mlRot(5,4) = -mlRot(1,2); // add translational and rotational parts ml = mlTrn + mlRot; // transform from local to global system M.addMatrixTripleProduct(0.0, Tgl, ml, 1.0); } } }