Changes

Jump to: navigation, search

TeamDS

87 bytes removed, 23:42, 4 April 2017
The code
=== The code ===
void Generate(const float src[], float dst[], int width, int height, int spread){ int spreadSize | class= spread * spread; int size = width * height; for (int i = 0; i < size; i++) { Vector2 localVec(i "wikitable mw-collapsible mw- ((i / width) * width), i / width); float shortestDist = MAX_FLOAT_VALUE; float pixelVal = src[i]; if (pixelVal > 0) // It's an inside pixel {collapsed" // Find closest outside pixel! NBody Hot Functions for (int j = 0; j < size; j++) { float pixelVal2 = src[j]; if (pixelVal2 == 0)// Outside pixel { // Calculate distance Vector2 targetVec(j |- ((j / width) * width), j / width); float dist = localVec.CalcDistance(targetVec); if (dist < shortestDist) shortestDist = dist; }|
<syntaxhighlight lang="cpp">void dowork(double t){ int numtimes=int(abs(t/dt)); dt=t/double(numtimes+1); numtimes=numtimes+1; for (int i=0;i<numtimes;i++){ CRO_step(dt,a); }}
float spread01 = void CRO_step(register double mydt,void (shortestDist / spread*a); if (spread01 > 1) spread01 ){ long double macr_a[4] = 1{0.5153528374311229364, -0.085782019412973646,0.4415830236164665242, 0.1288461583653841854}; // clamp it dst long double macr_b[i4] = (spread01 * {0.1344961992774310892, -0.2248198030794208058, 0.5f) + 7563200005156682911, 0.5f3340036032863214255}; } else // It's an outisde pixel for (int i=0;i<4;i++){ // Find closest inside pixel a(); for (int j = 0; j < sizencobjects; j++) { float pixelVal2 cobjects[j]->v += src cobjects[j]->a * mydt*macr_b[i]; if (pixelVal2 cobjects[j]-> 0)// Inside pixel { // Calculate distance Vector2 targetVec(pos += cobjects[j ]- ((j / width) >v * mydt* width), j / width)macr_a[i]; float dist = localVec.CalcDistance(targetVec); if (dist < shortestDist) shortestDist = dist; }
}
} //We should really expand the loop for efficiency
}
void calculate_a(){ for (int j1=0;j1<ncobjects;j1++){ cobjects[j1]->a=vect(0,0,0); } for (int j1=0; j1<ncobjects;j1++){ for (int j2=j1+1;j2<ncobjects;j2++){ double m1=cobjects[j1]->m; float spread01 double m2= cobjects[j2]->m; vect dist=cobjects[j1]->pos-cobjects[j2]->pos; double magd=dist.mag(shortestDist / spread); if vect base=dist*(spread01 > 1.0/(magd*magd*magd)) spread01 = 1; // clamp it dstcobjects[ij1] ->a+= base*(1 - spread01m2) ; cobjects[j2]->a+=base*.5fm1;
}
}
}
</syntaxhighlight>
 
|}
=== Assignment 2 ===
=== Assignment 3 ===
116
edits

Navigation menu