Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. 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;
  10. std::string powera2,tnta2,powera5,tnta5,signxt,signzt,direction;
  11. int xfpi,yfpi,zfpi;
  12. restart=1;
  13. powerq=1;
  14. while(restart==1){
  15. cout<<"Enter the x,y,z cord of the projectile."<<endl;
  16. cin>>xpost>>ypost>>zpost;
  17. cout<<"Enter the x,y,z cord of the power."<<endl;
  18. cin>>xposp>>yposp>>zposp;
  19. cout<<"Is the power a lined to a side or multiple. 1 for yes, 0 for no."<<endl;
  20. cin>>powera;
  21. if (powera==1){
  22. cout<<"What side the power aligned too? North, East, South, or West?"<<endl;
  23. cin>>powera2;
  24. if (powera2=="North"){
  25. powera3=1;
  26. }
  27. if (powera2=="South"){
  28. powera3=2;
  29. }
  30. if (powera2=="West"){
  31. powera3=3;
  32. }
  33. if (powera2=="East"){
  34. powera3=4;
  35. }
  36. cout<<"Is it aligned to another side? 1 for yes, 0 for no."<<endl;
  37. cin>>powera4;
  38. if (powera4==1){
  39. cout<<"What side the power aligned too also? North, East, South, or West?"<<endl;
  40. cin>>powera5;
  41. if (powera5=="North"){
  42. powera6=1;
  43. }
  44. if (powera5=="South"){
  45. powera6=2;
  46. }
  47. if (powera5=="West"){
  48. powera6=3;
  49. }
  50. if (powera5=="East"){
  51. powera6=4;
  52. }
  53. }
  54. }
  55. cout<<"Is the projectile aligned to a side or multiple. 1 for yes, 0 for no."<<endl;
  56. cin>>tnta;
  57. if (tnta==1){
  58. cout<<"What side the power aligned too? North, East, South, or West?"<<endl;
  59. cin>>tnta2;
  60. if (tnta2=="North"){
  61. tnta3=1;
  62. }
  63. if (tnta2=="South"){
  64. tnta3=2;
  65. }
  66. if (tnta2=="West"){
  67. tnta3=3;
  68. }
  69. if (tnta2=="East"){
  70. tnta3=4;
  71. }
  72. cout<<"Is it a lined to another side? 1 for yes, 0 for no."<<endl;
  73. cin>>tnta4;
  74. if (tnta4==1){
  75. cout<<"What side the power aligned too also? North, East, South, or West?"<<endl;
  76. cin>>powera5;
  77. if (tnta5=="North"){
  78. tnta6=1;
  79. }
  80. if (tnta5=="South"){
  81. tnta6=2;
  82. }
  83. if (tnta5=="West"){
  84. tnta6=3;
  85. }
  86. if (tnta5=="East"){
  87. tnta6=4;
  88. }
  89. }
  90. }
  91. cout<<"Is there a guider? If so enter 1 for yes, 0 for no."<<endl;
  92. cin>>guideque;
  93. if (guideque==1){
  94. yvolstop=0;
  95. cout<<"Enter the block under the guider."<<endl;
  96. cin>>yguider;
  97. }
  98. cout<<"Do you want this program to only search for 1x1? Enter 1 for yes, 0 for no."<<endl;
  99. cin>>searchh;
  100. if (searchh==1){
  101. cout<<"How many blocks from initial position would to like to search?"<<endl;
  102. cin>>blockl;
  103. cout<<"What is the max amount of tnt for the power to be search?"<<endl;
  104. cin>>maxpower;
  105. cout<<"Are you shooting for the x direction or z? Enter X or Z"<<endl;
  106. cin>>direction;
  107. }
  108. while(powerq==1){
  109. cout<<"Enter the amount of power tnt"<<endl;
  110. cin>>power;
  111. powerr=power;
  112. if (xpost>xposp){
  113. signxt="+";
  114. }
  115. if (xposp>xpost){
  116. signxt="-";
  117. }
  118. if (xposp==xpost){
  119. signxt="l";
  120. }
  121. if (zpost>zposp){
  122. signzt="+";
  123. }
  124. if (zposp>zpost){
  125. signzt="-";
  126. }
  127. if (zposp==zpost){
  128. signzt="l";
  129. }
  130. if (powera3==1){
  131. zposp=zposp-0.02;
  132. }
  133. if (powera3==2){
  134. zposp=zposp+0.02;
  135. }
  136. if (powera3==3){
  137. xposp=xposp-0.02;
  138. }
  139. if (powera3==4){
  140. xposp=xposp+0.02;
  141. }
  142. if (powera6==1){
  143. zposp=zposp-0.02;
  144. }
  145. if (powera6==2){
  146. zposp=zposp+0.02;
  147. }
  148. if (powera6==3){
  149. xposp=xposp-0.02;
  150. }
  151. if (powera6==4){
  152. zpost=zpost+0.02;
  153. }
  154. if (tnta6==3){
  155. xpost=xpost-0.02;
  156. }
  157. if (tnta6==4){
  158. xpost=xpost+0.02;
  159. }
  160. if (powera6==4){
  161. xposp=xposp+0.02;
  162. }
  163. if (tnta3==1){
  164. zpost=zpost-0.02;
  165. }
  166. if (tnta3==2){
  167. zpost=zpost+0.02;
  168. }
  169. if (tnta3==3){
  170. xpost=xpost-0.02;
  171. }
  172. if (tnta3==4){
  173. xpost=xpost+0.02;
  174. }
  175. if (tnta6==1){
  176. zpost=zpost-0.02;
  177. }
  178. if (tnta6==2){
  179. zpost=zpost+0.02;
  180. }
  181. if (tnta6==3){
  182. xpost=xpost-0.02;
  183. }
  184. if (tnta6==4){
  185. xpost=xpost+0.02;
  186. }
  187. xdis= sqrt(pow( (xposp-xpost), 2));
  188. zdis= sqrt(pow( (zposp-zpost), 2));
  189. ydis= sqrt(pow( (yposp-ypost), 2));
  190. xzhyp= sqrt((pow (xdis, 2))+(pow (zdis, 2)));
  191. hyp= sqrt((pow (xzhyp, 2))+(pow (ydis, 2)));
  192. xfp=0;
  193. zfp=0;
  194. yfp=0;
  195. cout<<"t"<<"="<<"-1"<<" ("<<xpost<<","<<ypost<<","<<zpost<<")"<<endl;
  196. t=0;
  197. while(t<81){
  198. if (signxt=="+"){
  199. xfp=(xpost+((((1-(0.125*hyp))*power*xdis)/hyp)*(pow((1-0.0199999809265137), t))))+xfp;
  200. }
  201. if (signxt=="-"){
  202. xfp=(xpost-((((1-(0.125)*hyp)*power*xdis)/hyp)*(pow((1-0.0199999809265137), t))))+xfp;
  203. }
  204. if (signxt=="l"){
  205. xfp=0;
  206. }
  207. if (signzt=="+"){
  208. zfp=(zpost+((((1-(0.125*hyp))*power*zdis)/hyp)*(pow((1-0.0199999809265137), t))))+zfp;
  209. }
  210. if (signzt=="-"){
  211. zfp=(zpost-((((1-(0.125*hyp))*power*zdis)/hyp)*(pow((1-0.0199999809265137), t))))+zfp;
  212. }
  213. if (signzt=="l"){
  214. zfp=0;
  215. }
  216. if (guideque==1){
  217. yfp=(yguider+(-0.03999999910593033*((pow (0.9800000190734863, t)-1)/(0.9800000190734863-1))));
  218. }
  219. if (guideque==0){
  220. yfp=(ypost+(-0.03999999910593033*((pow (0.9800000190734863, t)-1)/(0.9800000190734863-1)))+(((((1-(0.125*hyp))*power*ydis)/hyp)*(pow (0.9800000190734863, t)))))+yfp;
  221. }
  222. if (searchh==0){
  223. cout<<"t"<<"="<<t<<" (";
  224. if (xfp<=0){
  225. cout<<xfp;
  226. }
  227. else{
  228. cout<<xfp-t;
  229. }
  230. cout<<",";
  231. if (yfp<=0){
  232. cout<<yfp;
  233. }
  234. else{
  235. cout<<yfp-t;
  236. }
  237. cout<<",";
  238. if (zfp<=0){
  239. cout<<zfp;
  240. }
  241. else{
  242. cout<<zfp-t;
  243. }
  244. cout<<")"<<endl;
  245. t++;
  246. }
  247. if(searchh==1){
  248. if(direction=="X"){
  249. if (maxpower==power){
  250. cout<<"found nothing"<<endl;
  251. }
  252. if (power<=maxpower){
  253. if (t<81){
  254. if (((sqrt(pow(xfp, 2)))-(sqrt(pow(xpost, 2)))<blockl)){
  255. if(((xfp-floor(xfp))>0.98)){
  256. cout<<"t"<<"="<<t<<" "<<"power ="<<power<<" "<<" (";
  257. if (xfp<=0){
  258. cout<<xfp;
  259. }
  260. else{
  261. cout<<xfp-t;
  262. }
  263. cout<<",";
  264. if (yfp<=0){
  265. cout<<yfp;
  266. }
  267. else{
  268. cout<<yfp-t;
  269. }
  270. cout<<",";
  271. if (zfp<=0){
  272. cout<<zfp;
  273. }
  274. else{
  275. cout<<zfp-t;
  276. }
  277. cout<<")"<<endl;
  278. }
  279. if(((xfp-floor(xfp))<0.02)){
  280. cout<<"t"<<"="<<t<<" "<<"power ="<<power<<" "<<" (";
  281. if (xfp<=0){
  282. cout<<xfp;
  283. }
  284. else{
  285. cout<<xfp-t;
  286. }
  287. cout<<",";
  288. if (yfp<=0){
  289. cout<<yfp;
  290. }
  291. else{
  292. cout<<yfp-t;
  293. }
  294. cout<<",";
  295. if (zfp<=0){
  296. cout<<zfp;
  297. }
  298. else{
  299. cout<<zfp-t;
  300. }
  301. cout<<")"<<endl;
  302. }
  303.  
  304. }
  305. t++;
  306. continue;
  307.  
  308. }
  309. power++;
  310. t=0;
  311. }
  312. }
  313. if(direction=="Z"){
  314. if (t<81){
  315. while (power<=maxpower){
  316. if (((sqrt(pow(zfp, 2)))-(sqrt(pow(zpost, 2)))<blockl)){
  317. if(((zfp-floor(zfp))>0.98)){
  318. cout<<"t"<<"="<<t<<" "<<"power ="<<power<<" "<<" (";
  319. if (xfp<=0){
  320. cout<<xfp;
  321. }
  322. else{
  323. cout<<xfp-t;
  324. }
  325. cout<<",";
  326. if (yfp<=0){
  327. cout<<yfp;
  328. }
  329. else{
  330. cout<<yfp-t;
  331. }
  332. cout<<",";
  333. if (zfp<=0){
  334. cout<<xfp;
  335. }
  336. else{
  337. cout<<zfp-t;
  338. }
  339. cout<<")"<<endl;
  340. }
  341. if(((zfp-floor(zfp))<0.02)){
  342. cout<<"t"<<"="<<t<<" "<<"power ="<<power<<" "<<" (";
  343. if (xfp<=0){
  344. cout<<xfp;
  345. }
  346. else{
  347. cout<<xfp-t;
  348. }
  349. cout<<",";
  350. if (yfp<=0){
  351. cout<<yfp;
  352. }
  353. else{
  354. cout<<yfp-t;
  355. }
  356. cout<<",";
  357. if (zfp<=0){
  358. cout<<zfp;
  359. }
  360. else{
  361. cout<<zfp-t;
  362. }
  363. cout<<")"<<endl;
  364. }
  365.  
  366. }
  367. power++;
  368. }
  369. power=powerr;
  370. t++;
  371. }
  372. }
  373. }
  374. }
  375. t=-1;
  376. cout<<"would you like to keep the current setup and just change the amount of power? 1 for yes, 0 for no."<<endl;
  377. cin>>powerq;
  378.  
  379. }
  380. cout<<"Enter 1 to restart program or 0 to close"<<endl;
  381. cin>>restart;
  382. }
  383.  
  384.  
  385. return 0;
  386. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement