Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- int main()
- {
- double xpost,ypost,zpost,xposp,yposp,zposp,yguider,yvolstop,xdis,ydis,zdis,hyp,guideque,t,powera,tnta,powera3,tnta3,powera4,powera6,tnta4,tnta6,power,xzhyp,xfp,zfp,yfp,restart,powerq,searchh,blockl,maxpower,powerr;
- std::string powera2,tnta2,powera5,tnta5,signxt,signzt,direction;
- int xfpi,yfpi,zfpi;
- restart=1;
- powerq=1;
- while(restart==1){
- cout<<"Enter the x,y,z cord of the projectile."<<endl;
- cin>>xpost>>ypost>>zpost;
- cout<<"Enter the x,y,z cord of the power."<<endl;
- cin>>xposp>>yposp>>zposp;
- cout<<"Is the power a lined to a side or multiple. 1 for yes, 0 for no."<<endl;
- cin>>powera;
- if (powera==1){
- cout<<"What side the power aligned too? North, East, South, or West?"<<endl;
- cin>>powera2;
- if (powera2=="North"){
- powera3=1;
- }
- if (powera2=="South"){
- powera3=2;
- }
- if (powera2=="West"){
- powera3=3;
- }
- if (powera2=="East"){
- powera3=4;
- }
- cout<<"Is it aligned to another side? 1 for yes, 0 for no."<<endl;
- cin>>powera4;
- if (powera4==1){
- cout<<"What side the power aligned too also? North, East, South, or West?"<<endl;
- cin>>powera5;
- if (powera5=="North"){
- powera6=1;
- }
- if (powera5=="South"){
- powera6=2;
- }
- if (powera5=="West"){
- powera6=3;
- }
- if (powera5=="East"){
- powera6=4;
- }
- }
- }
- cout<<"Is the projectile aligned to a side or multiple. 1 for yes, 0 for no."<<endl;
- cin>>tnta;
- if (tnta==1){
- cout<<"What side the power aligned too? North, East, South, or West?"<<endl;
- cin>>tnta2;
- if (tnta2=="North"){
- tnta3=1;
- }
- if (tnta2=="South"){
- tnta3=2;
- }
- if (tnta2=="West"){
- tnta3=3;
- }
- if (tnta2=="East"){
- tnta3=4;
- }
- cout<<"Is it a lined to another side? 1 for yes, 0 for no."<<endl;
- cin>>tnta4;
- if (tnta4==1){
- cout<<"What side the power aligned too also? North, East, South, or West?"<<endl;
- cin>>powera5;
- if (tnta5=="North"){
- tnta6=1;
- }
- if (tnta5=="South"){
- tnta6=2;
- }
- if (tnta5=="West"){
- tnta6=3;
- }
- if (tnta5=="East"){
- tnta6=4;
- }
- }
- }
- cout<<"Is there a guider? If so enter 1 for yes, 0 for no."<<endl;
- cin>>guideque;
- if (guideque==1){
- yvolstop=0;
- cout<<"Enter the block under the guider."<<endl;
- cin>>yguider;
- }
- cout<<"Do you want this program to only search for 1x1? Enter 1 for yes, 0 for no."<<endl;
- cin>>searchh;
- if (searchh==1){
- cout<<"How many blocks from initial position would to like to search?"<<endl;
- cin>>blockl;
- cout<<"What is the max amount of tnt for the power to be search?"<<endl;
- cin>>maxpower;
- cout<<"Are you shooting for the x direction or z? Enter X or Z"<<endl;
- cin>>direction;
- }
- while(powerq==1){
- cout<<"Enter the amount of power tnt"<<endl;
- cin>>power;
- powerr=power;
- if (xpost>xposp){
- signxt="+";
- }
- if (xposp>xpost){
- signxt="-";
- }
- if (xposp==xpost){
- signxt="l";
- }
- if (zpost>zposp){
- signzt="+";
- }
- if (zposp>zpost){
- signzt="-";
- }
- if (zposp==zpost){
- signzt="l";
- }
- if (powera3==1){
- zposp=zposp-0.02;
- }
- if (powera3==2){
- zposp=zposp+0.02;
- }
- if (powera3==3){
- xposp=xposp-0.02;
- }
- if (powera3==4){
- xposp=xposp+0.02;
- }
- if (powera6==1){
- zposp=zposp-0.02;
- }
- if (powera6==2){
- zposp=zposp+0.02;
- }
- if (powera6==3){
- xposp=xposp-0.02;
- }
- if (powera6==4){
- zpost=zpost+0.02;
- }
- if (tnta6==3){
- xpost=xpost-0.02;
- }
- if (tnta6==4){
- xpost=xpost+0.02;
- }
- if (powera6==4){
- xposp=xposp+0.02;
- }
- if (tnta3==1){
- zpost=zpost-0.02;
- }
- if (tnta3==2){
- zpost=zpost+0.02;
- }
- if (tnta3==3){
- xpost=xpost-0.02;
- }
- if (tnta3==4){
- xpost=xpost+0.02;
- }
- if (tnta6==1){
- zpost=zpost-0.02;
- }
- if (tnta6==2){
- zpost=zpost+0.02;
- }
- if (tnta6==3){
- xpost=xpost-0.02;
- }
- if (tnta6==4){
- xpost=xpost+0.02;
- }
- xdis= sqrt(pow( (xposp-xpost), 2));
- zdis= sqrt(pow( (zposp-zpost), 2));
- ydis= sqrt(pow( (yposp-ypost), 2));
- xzhyp= sqrt((pow (xdis, 2))+(pow (zdis, 2)));
- hyp= sqrt((pow (xzhyp, 2))+(pow (ydis, 2)));
- xfp=0;
- zfp=0;
- yfp=0;
- cout<<"t"<<"="<<"-1"<<" ("<<xpost<<","<<ypost<<","<<zpost<<")"<<endl;
- t=0;
- while(t<81){
- if (signxt=="+"){
- xfp=(xpost+((((1-(0.125*hyp))*power*xdis)/hyp)*(pow((1-0.0199999809265137), t))))+xfp;
- }
- if (signxt=="-"){
- xfp=(xpost-((((1-(0.125)*hyp)*power*xdis)/hyp)*(pow((1-0.0199999809265137), t))))+xfp;
- }
- if (signxt=="l"){
- xfp=0;
- }
- if (signzt=="+"){
- zfp=(zpost+((((1-(0.125*hyp))*power*zdis)/hyp)*(pow((1-0.0199999809265137), t))))+zfp;
- }
- if (signzt=="-"){
- zfp=(zpost-((((1-(0.125*hyp))*power*zdis)/hyp)*(pow((1-0.0199999809265137), t))))+zfp;
- }
- if (signzt=="l"){
- zfp=0;
- }
- if (guideque==1){
- yfp=(yguider+(-0.03999999910593033*((pow (0.9800000190734863, t)-1)/(0.9800000190734863-1))));
- }
- if (guideque==0){
- yfp=(ypost+(-0.03999999910593033*((pow (0.9800000190734863, t)-1)/(0.9800000190734863-1)))+(((((1-(0.125*hyp))*power*ydis)/hyp)*(pow (0.9800000190734863, t)))))+yfp;
- }
- if (searchh==0){
- cout<<"t"<<"="<<t<<" (";
- if (xfp<=0){
- cout<<xfp;
- }
- else{
- cout<<xfp-t;
- }
- cout<<",";
- if (yfp<=0){
- cout<<yfp;
- }
- else{
- cout<<yfp-t;
- }
- cout<<",";
- if (zfp<=0){
- cout<<zfp;
- }
- else{
- cout<<zfp-t;
- }
- cout<<")"<<endl;
- t++;
- }
- if(searchh==1){
- if(direction=="X"){
- if (maxpower==power){
- cout<<"found nothing"<<endl;
- }
- if (power<=maxpower){
- if (t<81){
- if (((sqrt(pow(xfp, 2)))-(sqrt(pow(xpost, 2)))<blockl)){
- if(((xfp-floor(xfp))>0.98)){
- cout<<"t"<<"="<<t<<" "<<"power ="<<power<<" "<<" (";
- if (xfp<=0){
- cout<<xfp;
- }
- else{
- cout<<xfp-t;
- }
- cout<<",";
- if (yfp<=0){
- cout<<yfp;
- }
- else{
- cout<<yfp-t;
- }
- cout<<",";
- if (zfp<=0){
- cout<<zfp;
- }
- else{
- cout<<zfp-t;
- }
- cout<<")"<<endl;
- }
- if(((xfp-floor(xfp))<0.02)){
- cout<<"t"<<"="<<t<<" "<<"power ="<<power<<" "<<" (";
- if (xfp<=0){
- cout<<xfp;
- }
- else{
- cout<<xfp-t;
- }
- cout<<",";
- if (yfp<=0){
- cout<<yfp;
- }
- else{
- cout<<yfp-t;
- }
- cout<<",";
- if (zfp<=0){
- cout<<zfp;
- }
- else{
- cout<<zfp-t;
- }
- cout<<")"<<endl;
- }
- }
- t++;
- continue;
- }
- power++;
- t=0;
- }
- }
- if(direction=="Z"){
- if (t<81){
- while (power<=maxpower){
- if (((sqrt(pow(zfp, 2)))-(sqrt(pow(zpost, 2)))<blockl)){
- if(((zfp-floor(zfp))>0.98)){
- cout<<"t"<<"="<<t<<" "<<"power ="<<power<<" "<<" (";
- if (xfp<=0){
- cout<<xfp;
- }
- else{
- cout<<xfp-t;
- }
- cout<<",";
- if (yfp<=0){
- cout<<yfp;
- }
- else{
- cout<<yfp-t;
- }
- cout<<",";
- if (zfp<=0){
- cout<<xfp;
- }
- else{
- cout<<zfp-t;
- }
- cout<<")"<<endl;
- }
- if(((zfp-floor(zfp))<0.02)){
- cout<<"t"<<"="<<t<<" "<<"power ="<<power<<" "<<" (";
- if (xfp<=0){
- cout<<xfp;
- }
- else{
- cout<<xfp-t;
- }
- cout<<",";
- if (yfp<=0){
- cout<<yfp;
- }
- else{
- cout<<yfp-t;
- }
- cout<<",";
- if (zfp<=0){
- cout<<zfp;
- }
- else{
- cout<<zfp-t;
- }
- cout<<")"<<endl;
- }
- }
- power++;
- }
- power=powerr;
- t++;
- }
- }
- }
- }
- t=-1;
- cout<<"would you like to keep the current setup and just change the amount of power? 1 for yes, 0 for no."<<endl;
- cin>>powerq;
- }
- cout<<"Enter 1 to restart program or 0 to close"<<endl;
- cin>>restart;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement