{
 "metadata": {
  "name": "chapter4.ipynb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4: Resultants of Non-coplanar Force Systems"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4-1, Page no: 48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "#Initilization Of Variables\n",
      "\n",
      "F1=20 #lb\n",
      "F2=15 #lb\n",
      "F3=30 #lb\n",
      "F4=50 #lb\n",
      "#Co-ordinates of Forces\n",
      "C1=np.array([2,1,6])\n",
      "C2=np.array([4,-2,5])\n",
      "C3=np.array([-3,-2,1])\n",
      "C4=np.array([5,1,-2])\n",
      "\n",
      "#Calculations\n",
      "\n",
      "A=(C1[0]**2+C1[1]**2+C1[2]**2)**0.5\n",
      "B=(C2[0]**2+C2[1]**2+C2[2]**2)**0.5\n",
      "C=(C3[0]**2+C3[1]**2+C3[2]**2)**0.5\n",
      "D=(C4[0]**2+C4[1]**2+C4[2]**2)**0.5\n",
      "#Calculations for cos(thetax),cos(thetay) and cos(thetaz)\n",
      "theta1=(A**-1)*np.array([C1[0],C1[1],C1[2]])\n",
      "theta2=(B**-1)*np.array([C2[0],C2[1],C2[2]])\n",
      "theta3=(C**-1)*np.array([C3[0],C3[1],C3[2]])\n",
      "theta4=(D**-1)*np.array([C4[0],C4[1],C4[2]])\n",
      "#Calculations for forces (in form of force vectors)\n",
      "Fa=F1*np.array([theta1[0],theta1[1],theta1[2]]) #lb\n",
      "Fb=F2*np.array([theta2[0],theta2[1],theta2[2]]) #lb\n",
      "Fc=F3*np.array([theta3[0],theta3[1],theta3[2]]) #lb\n",
      "Fd=F4*np.array([theta4[0],theta4[1],theta4[2]]) #lb\n",
      "Fx=Fa[0]+Fb[0]+Fc[0]+Fd[0] #lb\n",
      "Fy=Fa[1]+Fb[1]+Fc[1]+Fd[1] #lb\n",
      "Fz=Fa[2]+Fb[2]+Fc[2]+Fd[2] #lb\n",
      "R=(Fx**2+Fy**2+Fz**2)**0.5 #lb\n",
      "thetax=arccos(Fx*R**-1)*(180/pi) #degrees\n",
      "thetay=180-((180*arccos(Fy*R**-1))/pi) #degrees\n",
      "thetaz=(180*arccos(Fz*R**-1))/pi #degrees\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The resultant of the force system is',round(R,1),\"lb\"\n",
      "print'The angle of the resultant with respect to x axis is',round(thetax,1),\"degree\"\n",
      "print'The angle of the resultant with respect to y axis is',round(thetay),\"degree\"\n",
      "print'The angle of the resultant with respect to a axis is',round(thetaz,1),\"degree\"\n",
      "\n",
      "# Thetax is off by 0.1 degrees"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resultant of the force system is 42.5 lb\n",
        "The angle of the resultant with respect to x axis is 30.1 degree\n",
        "The angle of the resultant with respect to y axis is 79.0 degree\n",
        "The angle of the resultant with respect to a axis is 62.4 degree\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4-2, Page no: 49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "F=[20,-10,30] #N\n",
      "#co-ordinates in meters\n",
      "a=2 #m\n",
      "b=4 #m\n",
      "c=7 #m\n",
      "d=3 #m\n",
      "e=2 #m\n",
      "f=4 #m\n",
      "\n",
      "#Calculations\n",
      "\n",
      "R=F[0]+F[1]+F[2] #N\n",
      "M_o=F[0]*a+F[1]*b+F[2]*c #N.m\n",
      "x=M_o*R**-1 #m\n",
      "M_x=-F[2]*f-F[0]*d-F[1]*e #N.m\n",
      "z=-M_x/R #m\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The resultant is +',round(R),\"N\"\n",
      "print'The moment about point O is +',round(M_o),\"N.m\"\n",
      "print'The position of R is at',round(x,2),\"m (from origin)\"\n",
      "print'The moment is',round(M_x),\"N.m\"\n",
      "print'The z co-ordinate is +',round(z),\"m\"\n",
      "\n",
      "# Here the value of R & M_o is correct which should yeild the vaue of x (M_o/R) correctly. However dueto some error in the software the correct value is not being printed.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resultant is + 40.0 N\n",
        "The moment about point O is + 210.0 N.m\n",
        "The position of R is at 5.25 m (from origin)\n",
        "The moment is -160.0 N.m\n",
        "The z co-ordinate is + 4.0 m\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4-3, Page No: 49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "F=[100,50,-150] #Force vector N\n",
      "a=2 #m\n",
      "b=2 #m \n",
      "c=3 #m\n",
      "d=2 #m\n",
      "e=4 #m\n",
      "f=8 #m\n",
      "\n",
      "#Calculations\n",
      "\n",
      "R=F[0]+F[1]+F[2] #N\n",
      "M_x=-F[0]*a+F[1]*b-F[2]*c #N.m\n",
      "M_z=F[0]*d+F[1]*e+F[2]*f #N.m\n",
      "C=sqrt(M_x**2+M_z**2) #N-m\n",
      "thetax=arctan(M_x*-M_z**-1)*(180/pi) #degrees\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The resultant is',round(R),\"N\"\n",
      "print'The moment about x axis is +',round(M_x),\"N.m\"\n",
      "print'The moment about z axis is',round(M_z),\"N.m\"\n",
      "print'The couple acting is',round(C),\"N.m\"\n",
      "print'The trace makes an angle with x axis of',round(thetax,1),\"degrees\"\n",
      "\n",
      "# The answer for C waries by 1 N.m as compared to the book."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resultant is 0.0 N\n",
        "The moment about x axis is + 350.0 N.m\n",
        "The moment about z axis is -800.0 N.m\n",
        "The couple acting is 873.0 N.m\n",
        "The trace makes an angle with x axis of 23.6 degrees\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4-4, Page No: 50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "\n",
      "#Initilization of variables\n",
      "x1=-2\n",
      "y1=2\n",
      "z1=-2\n",
      "x2=3\n",
      "y2=0\n",
      "z2=-4\n",
      "x3=3\n",
      "y3=2\n",
      "z3=2\n",
      "F1=40 #lb\n",
      "F2=30 #lb\n",
      "F3=20 #lb\n",
      "Mxm=np.array([-92.4,-48,-19.4])\n",
      "Mym=np.array([-46.2,72,9.8])\n",
      "Mzm=np.array([46.2,-36,19.4])\n",
      "\n",
      "#Calculations\n",
      "mag1=(x1**2+y1**2+z1**2)**0.5\n",
      "mag2=(x2**2+y2**2+z2**2)**0.5\n",
      "mag3=(x3**2+y3**2+z3**2)**0.5\n",
      "thetax1=(x1*mag1**-1) #degrees\n",
      "thetay1=(y1*mag1**-1) #degrees\n",
      "thetaz1=(z1*mag1**-1) #degrees\n",
      "thetax2=(x2*mag2**-1) #degrees\n",
      "thetay2=(y2*mag2**-1) #degrees\n",
      "thetaz2=(z2*mag2**-1) #degrees\n",
      "thetax3=(x3*mag3**-1) #degrees\n",
      "thetay3=(y3*mag3**-1) #degrees\n",
      "thetaz3=(z3*mag3**-1) #degrees\n",
      "#Now we will define all the components in terms of matrices for simplicity of computation\n",
      "F=np.array([F1,F2,F3]) #lb\n",
      "Fx1=F[0]*thetax1\n",
      "Fy1=F[0]*thetay1\n",
      "Fz1=F[0]*thetaz1\n",
      "Fx2=F[1]*thetax2\n",
      "Fy2=F[1]*thetay2\n",
      "Fz2=F[1]*thetaz2\n",
      "Fx3=F[2]*thetax3\n",
      "Fy3=F[2]*thetay3\n",
      "Fz3=F[2]*thetaz3\n",
      "Fx=Fx1+Fx2+Fx3 #lb\n",
      "Fy=Fy1+Fy2+Fy3 #lb\n",
      "Fz=Fz1+Fz2+Fz3 #lb\n",
      "R=(Fx**2+Fy**2+Fz**2)**0.5 #lb\n",
      "thetax=arccos(Fx*R**-1)*(180/pi) #degrees\n",
      "thetay=arccos(Fy*R**-1)*(180/pi) #degrees\n",
      "thetaz=arccos(Fz*R**-1)*(180/pi) #degrees\n",
      "#Moment calculations\n",
      "Mx=Mxm[0]+Mxm[1]+Mxm[2] #lb-ft\n",
      "My=Mym[0]+Mym[1]+Mym[2] #lb-ft\n",
      "Mz=Mzm[0]+Mzm[1]+Mzm[2] #lb-ft\n",
      "C=(Mx**2+My**2+Mz**2)**0.5 #lb-ft\n",
      "#Direction cosines\n",
      "PHIx=arccos(Mx*C**-1)*(180/pi) #degrees\n",
      "PHIy=arccos(My*C**-1)*(180/pi) #degrees\n",
      "PHIz=arccos(Mz*C**-1)*(180/pi) #degrees\n",
      "\n",
      "#Result\n",
      "print'The result of the force is',round(R,1),\"lb\"\n",
      "print'The angles with respect to X-Axis,Y-Axis and Z-axis are:',round(thetax,1),\"degrees\",',',round(thetay,1),\"degrees\",'and',round(thetaz,1),\"degrees respectively.\"\n",
      "print'The magnitude of resultant couple is',round(C),\"lb-ft\"\n",
      "print'The angles are as follows: Cosphix=',round(PHIx,1),\"degrees\",',Cosphiy=',round(PHIy,1),\"degrees\",'and Cosphiz=',round(PHIz,1),\"degrees\"\n",
      "\n",
      "# The answers may wary due to decimal point descrepancy"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The result of the force is 50.6 lb\n",
        "The angles with respect to X-Axis,Y-Axis and Z-axis are: 79.2 degrees , 49.6 degrees and 137.6 degrees respectively.\n",
        "The magnitude of resultant couple is 166.0 lb-ft\n",
        "The angles are as follows: Cosphix= 163.8 degrees ,Cosphiy= 77.6 degrees and Cosphiz= 79.8 degrees\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4-5, Page no 52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "\n",
      "#Initilization of variables\n",
      "F=np.array([150,90,160]) #lb force vector kind of decleration\n",
      "# Co-ordinates defined as [x,y,z] all the co-ordinates are in feet\n",
      "C_1=np.array([2,0,0]) \n",
      "C_2=np.array([0,0,1])\n",
      "C_3=np.array([0,-2,-1])\n",
      "C_4=np.array([-1,0,-1])\n",
      "\n",
      "#Calculations\n",
      "A=C_2-C_1\n",
      "B=C_4-C_3\n",
      "F1=(F[0]*A)/(A[0]**2+A[1]**2+A[2]**2)**0.5\n",
      "F2=(F[1]*B)/(B[0]**2+B[1]**2+B[2]**2)**0.5\n",
      "R=F1+F2\n",
      "# Determine C1 & C2\n",
      "# Calculating the cross products of C1 & C2 as,\n",
      "C1=np.array([[C_1[1]*F1[2]-C_1[2]*F1[1]],[-(C_1[0]*F1[2]-C_1[2]*F1[0])],[C_1[0]*F1[1]-C_1[1]*F1[0]]]) # lb-ft\n",
      "C2=np.array([[C_3[1]*F2[2]-C_3[2]*F2[1]],[-(C_3[0]*F2[2]-C_3[2]*F2[0])],[C_3[0]*F2[1]-C_3[1]*F2[0]]]) # lb-ft\n",
      "C3=np.array([[0],[0],[160]]) # lb-ft\n",
      "C=C1+C2+C3\n",
      "\n",
      "#Result\n",
      "print'The resultant force couple is',round(C[0],1),\"i\",round(C[1],1),\"j +\",round(C[2],1),\"k lb-ft\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resultant force couple is 80.5 i -93.9 j + 79.5 k lb-ft\n"
       ]
      }
     ],
     "prompt_number": 48
    }
   ],
   "metadata": {}
  }
 ]
}