{
 "metadata": {
  "name": "chapter 2.ipynb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2: Operations with Forces"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-1, Page No: 21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "F=20 #lb\n",
      "L=4.33 #ft\n",
      "#Calculation\n",
      "M=-F*L #lb-ft\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The moment of force F about O is',round(M,1),\"lb-ft\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The moment of force F about O is -86.6 lb-ft\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-2, Page no: 22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "F=20 #lb\n",
      "theta=((60*pi)/180) #radians\n",
      "L=5 #ft\n",
      "\n",
      "#Calculations\n",
      "\n",
      "F_x=F*cos(theta) #Resloving the vector\n",
      "F_y=F*sin(theta) #Resloving the vector\n",
      "M=-F_y*L #Appling Varignon's theorem\n",
      "#Negative sign tells that moment is clockwise\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The moment of the force about O is',round(M,1),\"lb-ft\"\n",
      " "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The moment of the force about O is -86.6 lb-ft\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-3,Page No: 22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "F=100 #N\n",
      "x1=2 #m\n",
      "x2=5 #m\n",
      "y1=0 #m\n",
      "y2=1 #m\n",
      "z1=4 #m\n",
      "z2=1 #m\n",
      "\n",
      "#Calculations\n",
      "\n",
      "xside=(x2-x1) #m\n",
      "yside=(y2-y1) #m\n",
      "zside=(z2-z1) #m\n",
      "LD=sqrt(xside**2+yside**2+zside**2)\n",
      "Fx=(xside/LD)*F #N\n",
      "Fy=(yside/LD)*F #N\n",
      "Fz=(zside/LD)*F #N\n",
      "Mx=-Fy*z1 #N-m\n",
      "My=Fx*x1-Fz*z1 #N-m\n",
      "Mz=Fy*x1 #N-m\n",
      "\n",
      "#Result\n",
      "\n",
      "print'Fx is',round(Fx,1),\"N\"\n",
      "print'Fy is',round(Fy,1),\"N\"\n",
      "print'Fz is',round(Fz,1),\"N\"\n",
      "print'Moment about X-Axis is',round(Mx,1),\"N.m\"\n",
      "print'Moment about Y-Axis is +',round(My),\"N.m\"\n",
      "print'Moment about Z-Axis is +',round(Mz,1),\"N.m\"\n",
      "\n",
      "# Decimal point error in calculation causes a small discrepancy in the resulting solutions."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fx is 68.8 N\n",
        "Fy is 22.9 N\n",
        "Fz is -68.8 N\n",
        "Moment about X-Axis is -91.8 N.m\n",
        "Moment about Y-Axis is + 413.0 N.m\n",
        "Moment about Z-Axis is + 45.9 N.m\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-4, Page No: 23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "Fx=68.7 #N\n",
      "Fy=22.9 #N\n",
      "Fz=-68.7 #N\n",
      "rx=2 #m\n",
      "ry=0 #m\n",
      "rz=4 #m\n",
      "rx1=5 #m\n",
      "ry1=1 #m\n",
      "rz1=1 #m\n",
      "\n",
      "#Calculation\n",
      "\n",
      "Mx=Fz*ry-Fy*rz #N-m\n",
      "My=-(Fz*rx-Fx*rz) #N-m\n",
      "Mz=Fy*rx-Fx*ry #N-m\n",
      "Mx1=Fz*ry1-Fy*rz1 #N-m\n",
      "My1=-(Fz*rx1-Fx*rz1) #N-m\n",
      "Mz1=Fy*rx1-Fx*ry1 #N-m\n",
      "\n",
      "#Result\n",
      "\n",
      "print'Moment with respect to origin using point(2,0,4)is',round(Mx,1),\"i +\",round(My),\"j +\",round(Mz,1),\"k N.m\"\n",
      "print'Moment with respect to origin using point (5,1,1) is',round(Mx1,1),\"i +\",round(My1),\"j +\",round(Mz1,1),\"k N.m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Moment with respect to origin using point(2,0,4)is -91.6 i + 412.0 j + 45.8 k N.m\n",
        "Moment with respect to origin using point (5,1,1) is -91.6 i + 412.0 j + 45.8 k N.m\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-5, Page no: 23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "Fx=2 #lb\n",
      "Fy=3 #lb\n",
      "Fz=-1 #lb\n",
      "rx=1 #ft\n",
      "ry=-4 #ft\n",
      "rz=3 #ft\n",
      "#Coordinates of points\n",
      "ax=3 #ft\n",
      "ay=1 #ft\n",
      "az=1 #ft\n",
      "bx=3 #ft\n",
      "by=-1 #ft\n",
      "bz=1 #ft\n",
      "cx=2 #ft\n",
      "cy=5 #ft\n",
      "cz=-2 #ft\n",
      "\n",
      "#Calculations\n",
      "\n",
      "Rx=ax-cx #ft\n",
      "Ry=ay-cy #ft\n",
      "Rz=az-cz #ft\n",
      "Mx=(Ry*Fz)-(Rz*Fy) #lb-ft\n",
      "My=-((Rx*Fz)-(Rz*Fx)) #lb-ft\n",
      "Mz=(Rx*Fy)-(Ry*Fx) #lb-ft\n",
      "E_u=sqrt((bx-cx)**2+(by-cy)**2+(bz-cz)**2) #ft\n",
      "ex=(bx-cx)/E_u #ft\n",
      "ey=(by-cy)/E_u #ft\n",
      "ez=(bz-cz)/E_u #ft\n",
      "M_lx=Mx*ex #lb-ft\n",
      "M_ly=My*ey #lb-ft\n",
      "M_lz=Mz*ez #lb-ft\n",
      "M_l=M_lx+M_ly+M_lz #lb-ft\n",
      "\n",
      "#Result\n",
      "\n",
      "print'Hence the moment about line is',round(M_l,2),\"lb-ft\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Hence the moment about line is -2.06 lb-ft\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-6, Page No: 24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "P_x=22 #N\n",
      "P_y=23 #N\n",
      "P_z=7 #N\n",
      "p1=1 #m\n",
      "p2=-1 #m\n",
      "p3=-2 #m\n",
      "\n",
      "#Calculations\n",
      "\n",
      "Mx=(p2*P_z)-(p3*P_y) #N-m\n",
      "My=-((p1*P_z)-(p3*P_x)) #N-m\n",
      "Mz=(p1*P_y)-(p2*P_x) #N-m\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The moment about the line from the origin is',round(Mx),\"i\",round(My),\"j +\",round(Mz),\"k N.m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The moment about the line from the origin is 39.0 i -51.0 j + 45.0 k N.m\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-8, Page No: 24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "F=10 #N Force couple\n",
      "a=3 #m Moment arm\n",
      "#Calculations\n",
      "C=-F*a #N-m\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The resultant couple is',round(C),\"N-m\" \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resultant couple is -30.0 N-m\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-11, Page No: 26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "C1=20 #N-m\n",
      "C2=40 #N-m\n",
      "C3=-55 #N-m\n",
      "\n",
      "#Calculations\n",
      "\n",
      "C=sqrt(C1**2+C2**2+C3**2) #N-m\n",
      "thetax=C2/C \n",
      "thetay=C3/C\n",
      "thetaz=C1/C\n",
      "Cx=C*thetax #N-m\n",
      "Cy=C*thetay #N-m\n",
      "Cz=C*thetaz #N-m\n",
      "\n",
      "#Result\n",
      "\n",
      "print'Couple in vector notation is',round(Cx),\"i\",round(Cy),\"j +\",round(Cz),\"k N.m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Couple in vector notation is 40.0 i -55.0 j + 20.0 k N.m\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-12,Page No: 26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "F1=25 #lb\n",
      "F2=25 #lb\n",
      "L1=14 #in\n",
      "L2=20 #in\n",
      "\n",
      "#Calculations\n",
      "\n",
      "C=F1*L1 #lb-in\n",
      "M=-F2*L2 #lb-in\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The twisting couple is',round(C),\"lb-in\"\n",
      "print'The bending moment is',round(M),\"lb-in\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The twisting couple is 350.0 lb-in\n",
        "The bending moment is -500.0 lb-in\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-13, Page No: 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "rx=20 #in\n",
      "ry=0 #in\n",
      "rz=14 #in\n",
      "Fx=0 #lb\n",
      "Fy=-25 #lb\n",
      "Fz=0 #lb\n",
      "\n",
      "#Calculation\n",
      "\n",
      "Mx=ry*Fz-rz*Fy #lb-in\n",
      "My=rx*Fz-rz*Fx #lb-in\n",
      "Mz=rx*Fy-ry*Fx #lb-in\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The moment of the 25-lb force is',round(Mx),\"i +\",round(My),\"j\",round(Mz),\"k lb-in\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The moment of the 25-lb force is 350.0 i + 0.0 j -500.0 k lb-in\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-14,Page No: 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "#Co-ordinates with respect to point O\n",
      "x=17.9 #ft\n",
      "y=6.91 #ft\n",
      "z=46.3 #ft\n",
      "Fz=-4000 #lb\n",
      "Fy=0 #lb\n",
      "\n",
      "#Calculation\n",
      "\n",
      "Mx=y*Fz-z*Fy #lb-ft\n",
      "\n",
      "#Result\n",
      "\n",
      "print'The scalar coefficient of the i term is the moment about the X-Axis is',round(Mx,3),\"lb-ft\"\n",
      "\n",
      "# The answer given in the textbook is incorrect"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The scalar coefficient of the i term is the moment about the X-Axis is -27640.0 lb-ft\n"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}