Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. // ch11_ex1_vang.cpp : Solves support forces for a beam.
  2. // Created/revised by Sebastian Vang on 11/22/17.
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <iomanip>
  7. #include <cmath>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.  
  14. // variables
  15. double gravity = 9.807;
  16. double Fg = 608.034;
  17. double answer = 0.0;
  18.  
  19. // array for mass
  20. double mass[10] = {100, 200, 300, 500, 800, 1300, 2100, 3400, 5500, 8900};
  21.  
  22. // function prototypes
  23. void getFm(double mass, double &Fm);
  24. void getTx(double Fm, double &Tx);
  25. void getTy(double Tx, double &Ty);
  26. void getAy(double Fm, double Ty, double &Ay);
  27. void getT(double Tx, double Ty, double &T);
  28. void getCableDiameter(double T, double &cd);
  29. void getPinDiameter(double Ax, double Ay, double &pd);
  30.  
  31. // counts from 0~10 for the mass
  32. for (int i = 0; i < 10; i++)
  33. {
  34. // displays mass in kg
  35. cout << fixed << setprecision(0);
  36. cout << "Mass: " << mass[i] << "kg" << endl;
  37.  
  38. // force applied to the beam
  39. getFm(mass[i], answer);
  40.  
  41. //cout << "Fm: " << answer << "N↓" << endl;
  42. double Fm = answer;
  43.  
  44. // function calls
  45. getTx(Fm, answer);
  46. cout << "Tx: " << answer << "N←" << endl;
  47. double Tx = answer;
  48. double Ax = Tx;
  49. cout << "Ax: " << Tx << "N→" << endl;
  50.  
  51. getTy(Tx, answer);
  52. cout << "Ty: " << answer << "N↑" << endl;
  53. double Ty = answer;
  54.  
  55. getAy(Fm, Ty, answer);
  56. cout << "Ay: " << answer << "N↑" << endl;
  57. double Ay = answer;
  58.  
  59. getT(Tx, Ty, answer);
  60. cout << "T: " << answer << "N" << endl;
  61. double T = answer;
  62.  
  63. // diameter of the cable
  64. getCableDiameter(T, answer);
  65. cout << fixed << setprecision(1);
  66. cout << "Cable Diameter: " << answer << "mm" << endl;
  67.  
  68. // diameter of the pin
  69. getPinDiameter(Ax, Ay, answer);
  70. cout << "Pin Diameter: " << answer << "mm" << endl;
  71.  
  72. cout << endl;
  73. }
  74. return 0;
  75. } // end of main function
  76.  
  77. // function definitions
  78.  
  79. void getFm(double mass, double &Fm)
  80. {
  81. Fm = mass * 9.807;
  82. } // end of getFm
  83.  
  84. void getTx(double Fm, double &Tx)
  85. {
  86. double Fg = 608.034;
  87. Tx = (8.796 * Fg + 11.856 * Fm) / 8.4;
  88. } // end of getFg
  89.  
  90. void getTy(double Tx, double &Ty)
  91. {
  92. Ty = Tx * tan(0.575347788);
  93. } // end of getTy
  94.  
  95. void getAy(double Fm, double Ty, double &Ay)
  96. {
  97. double Fg = 608.034;
  98. Ay = Fg + Fm - Ty;
  99. } // end of getAy
  100.  
  101. void getT(double Tx, double Ty, double &T)
  102. {
  103. T = sqrt(pow(Tx, 2) + pow(Ty, 2));
  104. } // end of getT
  105.  
  106. void getCableDiameter(double T, double &cd)
  107. {
  108. double L = 10.484;
  109. double delta = 0.000125;
  110. double E = 190 * pow(10,9);
  111. const double PI = 3.14159;
  112. cd = sqrt((4 * T * L) / (PI * delta * E)) * 1000;
  113. } // end of getCableDiameter
  114.  
  115. void getPinDiameter(double Ax, double Ay, double &pd)
  116. {
  117. const double PI = 3.14159;
  118. double O = (240 * pow(10, 6)) / 2;
  119. double Ar = sqrt(pow(Ax, 2) + pow(Ay, 2));
  120. pd = sqrt((4 * Ar) / (PI * O)) * 1000;
  121. } // end of getPinDiameter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement