TerrainHeightmap::TerrainHeightmap(QImage heightmap, bool blackIsHigh, double fact) :Terrain() { int height = heightmap.height(); int width = heightmap.width(); pointList = new Vector3 *[width]; for (int i = 0; i < width; i++) pointList[i] = new Vector3[height]; terrain_height = height; terrain_width = width; QColor it = (heightmap.pixel(0, 0)); double gray = blackIsHigh ? 255 - ((it.red() + it.blue() + it.green()) / 3) : ((it.red() + it.blue() + it.green()) / 3); high = gray * fact; low = gray * fact; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { it = (heightmap.pixel(i, j)); gray = blackIsHigh ? 255 - ((it.red() + it.blue() + it.green()) / 3) : ((it.red() + it.blue() + it.green()) / 3); pointList[i][j] = Vector3(i, j, gray * fact); MaxMin(gray * fact); } } calcK(); }
int main(void) { counter=0; while(counter++<5) { printf("What units is your current temperature:\n1 Kelvin\n2 Celsius\n3 Fahrenheit \n0 end\n"); scanf("%i", &unit); //Main serves as a directory to the functions required if(unit==1) //based on user input. calcK(); else if(unit==2) calcC(); else if(unit==3) calcF(); else if(unit==0) { printf("Goodbye\n"); counter=5; } else printf("%s", invalid); system("PAUSE"); } return 0; } // end main
// Renvoi un terrain généré aléatoirement TerrainFractal::TerrainFractal ( unsigned int terrain_width_, unsigned int terrain_height_ ) : Terrain ( ) { terrain_width = terrain_width_; terrain_height = terrain_height_; high = ( low = Noise::noise ( 0., 0. ) ); // Pour récuperer le Low and Height for ( unsigned int j = 0; j < terrain_height; j++ ) { for ( unsigned int i = 0; i < terrain_width; i++ ) { MaxMin ( Noise::noise ( i, j ) ); } } calcK ( ); }
CryptoPpDlogZpSafePrime::CryptoPpDlogZpSafePrime(ZpGroupParams * groupParams, mt19937 prg) { mt19937 prime_gen(clock()); // prg for prime checking this->random_element_gen = prg; biginteger p = groupParams->getP(); biginteger q = groupParams->getQ(); biginteger g = groupParams->getXg(); // if p is not 2q+1 throw exception if (!(q * 2 + 1 == p)) { throw invalid_argument("p must be equal to 2q+1"); } // if p is not a prime throw exception if (!miller_rabin_test(p, 40, prime_gen)) { throw invalid_argument("p must be a prime"); } // if q is not a prime throw exception if (!miller_rabin_test(q, 40, prime_gen)) { throw invalid_argument("q must be a prime"); } // set the inner parameters this->groupParams = groupParams; //Create CryptoPP Dlog group with p, ,q , g. //The validity of g will be checked after the creation of the group because the check need the pointer to the group pointerToGroup = new CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime(); pointerToGroup->Initialize(biginteger_to_cryptoppint(p), biginteger_to_cryptoppint(q), biginteger_to_cryptoppint(g)); //If the generator is not valid, delete the allocated memory and throw exception if (!pointerToGroup->ValidateElement(3, biginteger_to_cryptoppint(g), 0)){ delete pointerToGroup; throw invalid_argument("generator value is not valid"); } //Create the GroupElement - generator with the pointer that return from the native function generator = new ZpSafePrimeElementCryptoPp(g, p, false); //Now that we have p, we can calculate k which is the maximum length of a string to be converted to a Group Element of this group. k = calcK(p); }
CryptoPpDlogZpSafePrime::CryptoPpDlogZpSafePrime(int numBits, mt19937 prg) { this->random_element_gen = prg; // create random Zp dlog group and initialise it with the size and generator CryptoPP::AutoSeededRandomPool rng; //Random Number Generator pointerToGroup = new CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime(); pointerToGroup->Initialize(rng, numBits); // get the generator value CryptoPP::Integer gen = pointerToGroup->GetSubgroupGenerator(); //create the GroupElement - generator with the pointer that returned from the native function generator = new ZpSafePrimeElementCryptoPp(cryptoppint_to_biginteger(gen)); biginteger p = cryptoppint_to_biginteger(pointerToGroup->GetModulus()); biginteger q = cryptoppint_to_biginteger(pointerToGroup->GetSubgroupOrder()); biginteger xG = ((ZpElement *)generator)->getElementValue(); groupParams = new ZpGroupParams(q, xG, p); //Now that we have p, we can calculate k which is the maximum length in bytes of a string to be converted to a Group Element of this group. k = calcK(p); }