Boonas::Boonas(int argc, char** argv) { cursor = 0; orig = new LNHHolder(); temp = 0; colorValue = 0; Transformation matrix; if(argc < 3) { return; } if(strcmp(argv[1], "polygon") == 0) // DONE { polygon(argc, argv); // default the color to a grey, or a blue } else if(strcmp(argv[1], "polygonC") == 0) { polygonC(argc, argv); } else if(strcmp(argv[1], "assemble") == 0) // DONE { assemble(argc, argv); } else if(strcmp(argv[1], "transform") == 0) //WORKS { loadFile(argv[2]); // loads the data into a LNHHolder matrix = parseParams(3, argc, argv, matrix); doMult(matrix); // applies the matrix transformation writeFile(argv[2]); // writes file; } else if(strcmp(argv[1], "create") == 0) // WORKS { loadFile(argv[3]); matrix = parseParams(4, argc, argv, matrix); doMult(matrix); writeFile(argv[2]); } else if(strcmp(argv[1], "extrude") == 0) // WORKS { loadFile(argv[2]); doExtrude(argv[4], argv[3]); // extrudes argv 3 distance } else if(strcmp(argv[1], "clip") == 0) // clip, file, inpolies, outpolies, normalx normaly normalz, pointx, pointy, pointz { loadFile(argv[2]); //doClip(argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]); doClip(argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]); } else if(strcmp(argv[1], "rot") == 0) // rot infile outfile vectorx, y, z pointx, y, z, divisions, degrees { loadFile(argv[2]); doRotate(argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11]); writeFile(argv[3]); } return; }
int main() { int n,m; printf("Enter The Value of M and N: "); scanf("%d %d",&n,&m); doMult(m,n); return 0; }
void doTopDown(int a,int b) { printf("Enter Your Choise: \n" "1. Add\t 2.Subtract\t 3.Multiply\t4.Divide \n"); int choise; scanf("%d",&choise); switch(choise) { case 1:doAdd(a,b); break; case 2:doSub(a,b); break; case 3:doMult(a,b); break; case 4:doDiv(a,b); break; default: printf("Wrong Choise \n"); } }
void Boonas::doRotate(QString outfile, QString vectx, QString vecty, QString vectz, QString px, QString py, QString pz, QString divisions, QString degrees) { Point centerP(px.toFloat(), py.toFloat(), pz.toFloat()); Vector centerV(vectx.toFloat(), vecty.toFloat(), vectz.toFloat()); Transformation matrix; float theta; float phi; float angleOfRot = degrees.toFloat() / divisions.toFloat(); // translate to x matrix = xt(-px.toFloat(), matrix); matrix = yt(-py.toFloat(), matrix); matrix = zt(-pz.toFloat(), matrix); if(vectz.toFloat() == 0) { if((vectx.toFloat() == 1) && (vectz.toFloat() == 0)) { theta = 1.57079633; } else { theta = 0.0; } } else { theta = atan(vectx.toFloat() / vectz.toFloat()); } matrix = yr(-theta, matrix); phi = atan(vecty.toFloat() / (sqrt((vectx.toFloat() * vectx.toFloat()) + (vectz.toFloat() * vectz.toFloat())))); matrix = xr(phi, matrix); // apply matrix doMult(matrix); // do rotates and divisions along Z doZrm(outfile, angleOfRot, divisions.toFloat()); // have to re-read from a temp file after this delete orig; orig = new LNHHolder(); readTfile(outfile); //unrotate matrix = Transformation(); matrix = xr(-phi, matrix); matrix = yr(theta, matrix); // untranslate matrix = xt(px.toFloat(), matrix); matrix = yt(py.toFloat(), matrix); matrix = zt(pz.toFloat(), matrix); // apply matrix doMult(matrix); return; }
void Boonas::doZrm(QString outfile, float angleOfRot, float divisions) // angle of rot is in degrees { Transformation matrix; outfile.append(".polyTemp"); float x, y, z, w; bool again = true; QFile* theOutDestination; theOutDestination = new QFile(outfile); theOutDestination -> remove(); theOutDestination -> open(QIODevice::ReadWrite | QIODevice::Text); QTextStream outStream( theOutDestination ); matrix = zd(angleOfRot, matrix); for(int i = 0; i < divisions; i++) // do it for the total number of divisions { again = true; orig -> reset(); //write to file do // do this loop while ther is more in orig { cursor = orig -> getCurrent(); // cursor is current cursor -> reset(); //change color respectively for each object x = cursor -> getX(); y = cursor -> getY(); z = cursor -> getZ(); if(colorValue != 0) { delete colorValue; colorValue = 0; } colorValue = new Point(x, y, z); cursor -> advance(); x = cursor -> getX(); y = cursor -> getY(); z = cursor -> getZ(); if(!(orig -> isNotLast())) { again = false; } outStream << "newObject" << endl; // put out color vector outStream << colorValue -> x() << " " << colorValue -> y() << " "<< colorValue -> z() << " 1" << endl; do { x = cursor -> getX(); // get point y = cursor -> getY(); z = cursor -> getZ(); w = cursor -> getW(); outStream << x << " " << y << " " << z << " " << w << endl; //qDebug() << "runing through before mult then after"; //qDebug() << x << " " << y << " " << z << " " << w; cursor -> advance(); } while(cursor -> hasNext()); // run through the points and mult! x = cursor -> getX(); // get point y = cursor -> getY(); z = cursor -> getZ(); w = cursor -> getW(); outStream << x << " " << y << " " << z << " " << w << endl; cursor -> reset(); orig -> advance(); // advance what were working with } while(again); //do rotate doMult(matrix); } return; }