void RandomModel::antennasProduce() { Direction tad(0,0,1); Direction tarp(0,0,0); Direction taPolar(sqrt(double(2))/2, 0, sqrt(double(2))/2); Antenna ta(tad, tarp, taPolar, 10); this->tAntennas.push_back(ta); Direction rad(0,0,1); Direction rarp(0,0,0); Direction raVPolar(1, 0, 0); Direction raHPolar(0, 0, 1); Antenna ra(rad, rarp, raVPolar, raHPolar); this->rAntennas.push_back(ra); }
int nodeup_postmove(int argc, char *argv[]) { int c, i; if (nodeup_mnt_proc(PROC_TMP)) return -1; while ((c = getopt(argc, argv, "")) != -1) { switch (c) { default: return -1; } } for (i=optind; i < argc; i++) { log_print(LOG_INFO, "performing RARP on %s\n", argv[i]); if (rarp(argv[i], 1, 5*60)) return -1; } return 0; }
// 随机模型1 Model randomModel(double length, double width, double margin, double sMaxH, double sMinH, double sMaxW, double sMinW, double surfaceInterval, double vRange, int dFlag) { Direction* tdp; Direction* rdp; switch(dFlag) { case 1: tdp = new Direction(0, 1, 0); rdp = new Direction(0, 1, 0); break; case 2: tdp = new Direction(0, -1, 0); rdp = new Direction(0, -1, 0); break; case 3: tdp = new Direction(0, 1, 0); rdp = new Direction(0, -1, 0); break; case 4: tdp = new Direction(0, -1, 0); rdp = new Direction(0, 1, 0); break; default: double ty = plusOrMinus(); double ry = plusOrMinus(); Direction td(0, ty, 0); Direction rd(0, ry, 0); break; } Vehicle tx = randomVehicle(0, width, *tdp, vRange); Vehicle rx = randomVehicle(length, width, *rdp, vRange); vector<Material> materials = materialList(); vector<Surface> surfaces; double totalLength = 0; srand((int)time(0)); while (totalLength <= length) { double x0 = (width / 2) + random((int)margin); double y0 = totalLength; double z0 = sMinH + random(int(sMaxH - sMinH)); Point p0(x0, y0, z0); double sWidth = sMinW + random((int)(sMaxW - sMinW)); double x1 = x0; double y1 = y0 + sWidth; double z1 = 0; Point p1(x1, y1, z1); Surface s(p0, p1); surfaces.push_back(s); totalLength = y0 + sWidth + random((int)surfaceInterval); } totalLength = 0; while (totalLength <= length) { double x0 = -((width / 2) + random((int)margin)); double y0 = totalLength; double z0 = sMinH + random(int(sMaxH - sMinH)); Point p0(x0, y0, z0); double sWidth = sMinW + random((int)(sMaxW - sMinW)); double x1 = x0; double y1 = y0 + sWidth; double z1 = 0; Point p1(x1, y1, z1); Surface s(p0, p1); surfaces.push_back(s); totalLength = y0 + sWidth + random((int)surfaceInterval); } int sizeM = materials.size(); for (int i = 0; i < (int)surfaces.size(); i++) { int indexM = random(sizeM); surfaces[i].setMaterial(materials[indexM]); surfaces[i].init(); } Direction tad(0,0,1); Direction tarp(0,0,0); Direction taPolar(sqrt(double(2))/2, 0, sqrt(double(2))/2); Antenna ta(tad, tarp, taPolar, 10); vector<Antenna> tas; tas.push_back(ta); Direction rad(0,0,1); Direction rarp(0,0,0); Direction raVPolar(1, 0, 0); Direction raHPolar(0, 0, 1); Antenna ra(rad, rarp, raVPolar, raHPolar); vector<Antenna> ras; ras.push_back(ra); Model model(tx, rx, surfaces, tas, ras); return model; }