Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ch11_ex1_vang.cpp : Solves support forces for a beam.
- // Created/revised by Sebastian Vang on 11/22/17.
- #include "stdafx.h"
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- int main()
- {
- // variables
- double gravity = 9.807;
- double Fg = 608.034;
- double answer = 0.0;
- // array for mass
- double mass[10] = {100, 200, 300, 500, 800, 1300, 2100, 3400, 5500, 8900};
- // function prototypes
- void getFm(double mass, double &Fm);
- void getTx(double Fm, double &Tx);
- void getTy(double Tx, double &Ty);
- void getAy(double Fm, double Ty, double &Ay);
- void getT(double Tx, double Ty, double &T);
- void getCableDiameter(double T, double &cd);
- void getPinDiameter(double Ax, double Ay, double &pd);
- // counts from 0~10 for the mass
- for (int i = 0; i < 10; i++)
- {
- // displays mass in kg
- cout << fixed << setprecision(0);
- cout << "Mass: " << mass[i] << "kg" << endl;
- // force applied to the beam
- getFm(mass[i], answer);
- //cout << "Fm: " << answer << "N↓" << endl;
- double Fm = answer;
- // function calls
- getTx(Fm, answer);
- cout << "Tx: " << answer << "N←" << endl;
- double Tx = answer;
- double Ax = Tx;
- cout << "Ax: " << Tx << "N→" << endl;
- getTy(Tx, answer);
- cout << "Ty: " << answer << "N↑" << endl;
- double Ty = answer;
- getAy(Fm, Ty, answer);
- cout << "Ay: " << answer << "N↑" << endl;
- double Ay = answer;
- getT(Tx, Ty, answer);
- cout << "T: " << answer << "N" << endl;
- double T = answer;
- // diameter of the cable
- getCableDiameter(T, answer);
- cout << fixed << setprecision(1);
- cout << "Cable Diameter: " << answer << "mm" << endl;
- // diameter of the pin
- getPinDiameter(Ax, Ay, answer);
- cout << "Pin Diameter: " << answer << "mm" << endl;
- cout << endl;
- }
- return 0;
- } // end of main function
- // function definitions
- void getFm(double mass, double &Fm)
- {
- Fm = mass * 9.807;
- } // end of getFm
- void getTx(double Fm, double &Tx)
- {
- double Fg = 608.034;
- Tx = (8.796 * Fg + 11.856 * Fm) / 8.4;
- } // end of getFg
- void getTy(double Tx, double &Ty)
- {
- Ty = Tx * tan(0.575347788);
- } // end of getTy
- void getAy(double Fm, double Ty, double &Ay)
- {
- double Fg = 608.034;
- Ay = Fg + Fm - Ty;
- } // end of getAy
- void getT(double Tx, double Ty, double &T)
- {
- T = sqrt(pow(Tx, 2) + pow(Ty, 2));
- } // end of getT
- void getCableDiameter(double T, double &cd)
- {
- double L = 10.484;
- double delta = 0.000125;
- double E = 190 * pow(10,9);
- const double PI = 3.14159;
- cd = sqrt((4 * T * L) / (PI * delta * E)) * 1000;
- } // end of getCableDiameter
- void getPinDiameter(double Ax, double Ay, double &pd)
- {
- const double PI = 3.14159;
- double O = (240 * pow(10, 6)) / 2;
- double Ar = sqrt(pow(Ax, 2) + pow(Ay, 2));
- pd = sqrt((4 * Ar) / (PI * O)) * 1000;
- } // end of getPinDiameter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement