{
 "metadata": {
  "name": "appendix.ipynb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Appendix"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-1,Page No:638"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "#Initilization of variables\n",
      "\n",
      "P=[-5,2,14] #Point co-ordinates\n",
      "\n",
      "#Calculations\n",
      "r=(P[0]**2+P[1]**2+P[2]**2)**0.5 #Magnitude of the poistion vector\n",
      "\n",
      "#Direction cosines\n",
      "l=P[0]/r \n",
      "m=P[1]/r\n",
      "n=P[2]/r\n",
      "\n",
      "\n",
      "#Unit Vector calculations\n",
      "\n",
      "r_unit=[l,m,n]\n",
      "\n",
      "#Results\n",
      "\n",
      "print\"The unit vector in the direction of r is \",round(r_unit[0],2),\"i +\",round(r_unit[1],3),\"j +\",round(r_unit[2],3),\"k\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The unit vector in the direction of r is  -0.33 i + 0.133 j + 0.933 k\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-2,Page No:639"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilizatin of variable\n",
      "F=10 #N\n",
      "P_1=[2,4,3] \n",
      "P_2=[1,-5,2]\n",
      "\n",
      "#Calculations\n",
      "d_x=P_2[0]-P_1[0] \n",
      "d_y=P_2[1]-P_1[1]\n",
      "d_z=P_2[2]-P_1[2]\n",
      "d=(d_x**2+d_y**2+d_z**2)**0.5\n",
      "Fx=(F/d)*d_x #N\n",
      "Fy=(F/d)*d_y #N\n",
      "Fz=(F/d)*d_z #N\n",
      "#Direction cosines\n",
      "l=Fx/F\n",
      "m=Fy/F\n",
      "n=Fz/F\n",
      "#Angles\n",
      "theta_x=arccos(l)*(180/pi) #degrees\n",
      "theta_y=arccos(m)*(180/pi) #degrees\n",
      "theta_z=arccos(n)*(180/pi) #degrees\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The force in vector notation is \",round(Fx,1),\"i \",round(Fy,2),\"j \",round(Fz,1),\"k\"\n",
      "print\"Thetax=\",round(theta_x,1),\" degrees\",\"\",  \"Thetay=\",round(theta_y,2),\"degrees\",\"\",  \"Thetaz=\",round(theta_z,1), \"degrees\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The force in vector notation is  -1.1 i + -9.88 j + -1.1 k\n",
        "Thetax= 96.3  degrees  Thetay= 171.07 degrees  Thetaz= 96.3 degrees\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-3,Page No:640"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initiliation of variables\n",
      "T=2500 #N\n",
      "\n",
      "#Co-ordinates\n",
      "Q=[40,0,-30]\n",
      "P=[0,80,0]\n",
      "\n",
      "#Calculations\n",
      "mag_QP=sqrt((P[0]-Q[0])**2+(P[1]-Q[1])**2+(P[2]-Q[2])**2) #Magnitude\n",
      "QP=[(P[0]-Q[0]),(P[1]-Q[1]),(P[2]-Q[2])] \n",
      "F=(T*mag_QP**-1)*QP #N\n",
      "thetax=arccos(F[0]/T)*(180/pi) #degrees\n",
      "thetay=arccos(F[1]/T)*(180/pi) #degrees\n",
      "thetaz=arccos(F[2]/T)*(180/pi) #degrees\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The force vector is \",round(F[0]),\"i  +\",round(F[1]),\"j  +\",round(F[2]),\"k\"\n",
      "\n",
      "#Answer in the textbook is printed as 1600 which is incorrect\n",
      "print\"The angles are thetax=\",round(thetax,1),\"degrees\",\"\",\"thetay=\",round(thetay),\" degrees\",\"\",\" thetaz=\",round(thetaz,1),\" degrees\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The force vector is  -40.0 i  + 80.0 j  + 30.0 k\n",
        "The angles are thetax= 180.0 degrees  thetay= 90.0  degrees   thetaz= 90.0  degrees\n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-4,Page No:642"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initilization of variables\n",
      "\n",
      "A=[2,-1,1]\n",
      "B=[1,1,2]\n",
      "C=[3,-2,4]\n",
      "\n",
      "#Calculations\n",
      "\n",
      "R=[A[0]+B[0]+C[0],A[1]+B[1]+C[1],A[2]+B[2]+C[2]] #Resultant\n",
      "R1=[R[0],R[1],R[2]]\n",
      "mag=sqrt(R[0]**2+R[1]**2+R[2]**2)\n",
      "\n",
      "#Unit vector\n",
      "U=R1/mag \n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The unit vector is \",round(U[0],3),\"i\",round(U[1],3),\"j +\",round(U[2],2),\"k\"\n",
      "#Answer for k part is incorrect in the textbook\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The unit vector is  0.636 i -0.212 j + 0.74 k\n"
       ]
      }
     ],
     "prompt_number": 47
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-5,Page No:642"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initilization of variables\n",
      "A=[2,-6,-3]\n",
      "B=[4,3,-1] \n",
      "\n",
      "#Calculations\n",
      "\n",
      "AdotB=A[0]*B[0]+A[1]*B[1]+A[2]*B[2] \n",
      "magA=sqrt(A[0]**2+A[1]**2+A[2]**2) \n",
      "magB=sqrt(B[0]**2+B[1]**2+B[2]**2)\n",
      "theta=arccos(AdotB/(magA*magB))*(180/pi) #degrees\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The product of both the vectors is \",round(AdotB)\n",
      "print\"The angle between them is \",round(theta,1),\"degrees\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The product of both the vectors is  -7.0\n",
        "The angle between them is  101.3 degrees\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-6,Page No:643"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initilization of variables\n",
      "\n",
      "A=[4,-3,1]\n",
      "P=[2,3,-1]\n",
      "Q=[-2,-4,3]\n",
      "\n",
      "#Calculations\n",
      "\n",
      "B=[Q[0]-P[0],Q[1]-P[1],Q[2]-P[2]]\n",
      "AdotB=A[0]*B[0]+A[1]*B[1]+A[2]*B[2]\n",
      "magB=sqrt(B[0]**2+B[1]**2+B[2]**2)\n",
      "A_costheta=AdotB/magB\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The value of A_costheta is \",round(A_costheta)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The value of A_costheta is  1.0\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-7,Page No:643"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilization of variables\n",
      "\n",
      "F=[5,10,-15]\n",
      "a=[1,0,3]\n",
      "b=[3,-1,-6]\n",
      "\n",
      "#Calculations\n",
      "\n",
      "d=[b[0]-a[0],b[1]-a[1],b[2]-a[2]]\n",
      "\n",
      "Work_done=(F[0]*d[0])+(F[1]*d[1])+(F[2]*d[2])\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The work done is \",round(Work_done)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The work done is  135.0\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-8,Page No:644"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initilization of variables\n",
      "A=[2,-6,-3]\n",
      "B=[4,3,-1]\n",
      "\n",
      "#Calculations\n",
      "\n",
      "AcrossB=[(A[1]*B[2]-B[1]*A[2]),A[2]*B[0]-A[0]*B[2],A[0]*B[1]-A[1]*B[0]]\n",
      "mag=sqrt(AcrossB[0]**2+AcrossB[1]**2+AcrossB[2]**2)\n",
      "n=AcrossB/mag\n",
      "magA=(A[0]**2+A[1]**2+A[2]**2)**0.5\n",
      "magB=(B[0]**2+B[1]**2+B[2]**2)**0.5\n",
      "theta=arcsin(mag/(magA*magB))*(180/pi)\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The cross prcoduct of the two vectors is \",AcrossB[0],\"i\",AcrossB[1],\"j\",AcrossB[2],\"k\"\n",
      "print\"The angle between the two is \",round(theta,1),\"degrees\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The cross prcoduct of the two vectors is  15 i -10 j 30 k\n",
        "The angle between the two is  78.7 degrees\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-9,Page No:645"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Initilizatin of variable\n",
      "omega=2 # rad/second\n",
      "A=[0,1,2] \n",
      "B=[1,3,-2]\n",
      "P=[3,6,4]\n",
      "\n",
      "#Calculations\n",
      "\n",
      "# Point co-ordinates of axis of rotation is \n",
      "S=[1,2,-4]\n",
      "R=sqrt(S[0]**2+S[1]**2+S[2]**2) # magnitude of position vector\n",
      "# Unit vector calculations along axis of rotation\n",
      "R_unit=S/R\n",
      "w=omega*R_unit\n",
      "# Position vector calculations\n",
      "r=(P[0]-A[0])+(P[1]-A[1])+(P[2]-A[2])\n",
      "v=w*r\n",
      "# Magnitude of v \n",
      "v_mag=sqrt(v[0]**2+v[1]**2+v[2]**2)\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The linear velocity of point P is \",round(v_mag)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The linear velocity of point P is  20.0\n"
       ]
      }
     ],
     "prompt_number": 51
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-10,Page No:647"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialization\n",
      "\n",
      "O=[-2,3,5]\n",
      "F=[4,4,-1]\n",
      "P=[1,-2,4]\n",
      "Q=[5,2,3]\n",
      "\n",
      "#Calculation\n",
      "\n",
      "r1=[P[0]-O[0],P[1]-O[1],P[2]-O[2]]\n",
      "\n",
      "moment=[(r1[1]*F[2]-r1[2]*F[1]),(r1[2]*F[0]-r1[0]*F[2]),(r1[0]*F[1]-r1[1]*F[0])] #momentum\n",
      "\n",
      "r2=[Q[0]-O[0],Q[1]-O[1],Q[2]-O[2]]\n",
      "\n",
      "moment1=[(r2[1]*F[2]-r2[2]*F[1]),(r2[2]*F[0]-r2[0]*F[2]),(r2[0]*F[1]-r2[1]*F[0])]#momentum\n",
      "\n",
      "#result\n",
      "\n",
      "print\"The moment about point O is \",round(moment[0],3),\"i\",round(moment[1],3),\"j +\",round(moment[2],3),\"k\"\n",
      "print\"The moment about point O is \",round(moment1[0],3),\"i\",round(moment1[1],3),\"j +\",round(moment1[2],3),\"k\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The moment about point O is  9.0 i -1.0 j + 32.0 k\n",
        "The moment about point O is  9.0 i -1.0 j + 32.0 k\n"
       ]
      }
     ],
     "prompt_number": 62
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-11,Page No:647"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialization\n",
      "\n",
      "F=[3,2,-4]\n",
      "P=[1,-1,2]\n",
      "O=[2,-1,3]\n",
      "\n",
      "#Calculation\n",
      "\n",
      "r=[P[0]-O[0],P[1]-O[1],P[2]-O[2]]\n",
      "\n",
      "M=[(r[1]*F[2]-r[2]*F[1]),(r[2]*F[0]-r[0]*F[2]),(r[0]*F[1]-r[1]*F[0])]\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The moment of force about point O is \",round(M[0]),\"i\",round(M[1]),\"j +\",round(M[2]),\"k\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The moment of force about point O is  2.0 i -7.0 j + -2.0 k\n"
       ]
      }
     ],
     "prompt_number": 64
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-12,Page No:648"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initiaization\n",
      "\n",
      "A=[4,-1,7]\n",
      "O=[1,-3,2]\n",
      "V=[9,6,-2]\n",
      "\n",
      "#Clalculation\n",
      "\n",
      "mag_v=sqrt(V[0]**2+V[1]**2+V[2]**2)\n",
      "\n",
      "F=[(22/mag_v)*V[0],(22/mag_v)*V[1],(22/mag_v)*V[2]]\n",
      "\n",
      "r=[A[0]-O[0],A[1]-O[1],A[2]-O[2]]\n",
      "\n",
      "M=[r[1]*F[2]-F[1]*r[2],r[0]*F[2]-r[2]*F[0],r[0]*F[1]-r[1]*F[0]]\n",
      "\n",
      "#result\n",
      "\n",
      "print\"\",round(M[0]),\"i\",\"+\",round(M[1]),\"j\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " -68.0 i + -102.0 j\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-13,Page No:648"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialization\n",
      "\n",
      "F=[50,-80,30]\n",
      "\n",
      "#Calculation\n",
      "\n",
      "#unit vector in u direction\n",
      "u=[cos(30*(pi/180)),cos(60*(pi/180)),cos(90*(pi/180))]\n",
      "#unit vector in v direction\n",
      "v=[1*cos(120*(pi/180)),1*cos(30*(pi/180)),1*cos(90*(pi/180))]\n",
      "#unit vector in w direction\n",
      "w=[1*cos(90*(pi/180)),1*cos(90*(pi/180)),1*cos(0*(pi/180))]\n",
      "\n",
      "#component of force F\n",
      "\n",
      "U=F[0]*u[0]+F[1]*u[1]+F[2]*u[2] #component force along u\n",
      "V=F[0]*v[0]+F[1]*v[1]+F[2]*v[2] #component force along v\n",
      "W=F[0]*w[0]+F[1]*w[1]+F[2]*w[2] #component force along w\n",
      "\n",
      "\n",
      "#Result\n",
      "print\"the component force along u is \",round(U,1)\n",
      "print\"the component force along v is \",round(V,2)\n",
      "print\"the component force along w is \",round(W,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the component force along u is  3.3\n",
        "the component force along v is  -94.28\n",
        "the component force along w is  30.0\n"
       ]
      }
     ],
     "prompt_number": 90
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-14,Page No:649"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialization\n",
      "\n",
      "\n",
      "F_v=100 #N\n",
      "A=[0,0,0]\n",
      "B=[0.5,0,0]\n",
      "C=[0.5,0,1]\n",
      "D=[0,0,1]\n",
      "E=[0,0.5,0]\n",
      "F=[0.5,0.5,0]\n",
      "G=[0.5,0.5,1]\n",
      "H=[0,0.5,1]\n",
      "\n",
      "#Calculation\n",
      "\n",
      "F_vec=F_v/sqrt((F[0]-C[0])**2+(F[1]-C[1])**2+(F[2]-C[2])**2)\n",
      "F_x=(F[0]-C[0])*F_vec\n",
      "F_y=(F[1]-C[1])*F_vec\n",
      "F_z=(F[2]-C[2])*F_vec\n",
      "\n",
      "F=[F_x,F_y,F_z]\n",
      "\n",
      "#moment about point E\n",
      "\n",
      "#taking position vector r directed from E on force F\n",
      "r_ec=[C[0]-E[0],C[1]-E[1],C[2]-E[2]]\n",
      "\n",
      "#M_e=r_ec*F\n",
      "\n",
      "M_e=[(r_ec[1]*F[2]-r_ec[2]*F[1]),(r_ec[0]*F[2]-r_ec[2]*F[0]),(r_ec[0]*F[1]-r_ec[1]*F[0])]\n",
      "\n",
      "#unit vector in direction AE is n_ae\n",
      "\n",
      "n_ae=[0,1,0]\n",
      "\n",
      "#moment about axis AE\n",
      "#M_ae=M_e*n_ae\n",
      "\n",
      "M_ae=[M_e[0]*n_ae[0],M_e[1]*n_ae[1],M_e[2]*n_ae[2]] \n",
      "\n",
      "#result\n",
      "\n",
      "print\"moment of force about E is \",round(M_e[0]),\"i\",round(M_e[1]),\"j +\",round(M_e[2]),\"k\"  #answer given in book is wrong   \n",
      "print\"moment of force about axis AE is \",round(M_ae[0]),\"i\",round(M_ae[1]),\"j +\",round(M_ae[2]),\"k\"  #answer given in book is wrong "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "moment of force about E is  0.0 i -45.0 j + 22.0 k\n",
        "moment of force about axis AE is  0.0 i -45.0 j + 0.0 k\n"
       ]
      }
     ],
     "prompt_number": 103
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-15,Page No:652"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialization\n",
      "F_1=5 #kN\n",
      "F_2=7.5 #kN\n",
      "F_3=10 #kN\n",
      "A=[0,0,0]\n",
      "E=[0,1,0]\n",
      "D=[0,0,2]\n",
      "F=[3,1,0]\n",
      "G=[3,1,2]\n",
      "H=[0,1,2]\n",
      "#calculation\n",
      "\n",
      "F1=[F_1*3**-1*(F[0]-E[0]),F_1/3*(F[1]-E[1]),F_1/3*(F[2]-E[2])] #5/sqrt(9)=5/3\n",
      "F2=[F_2*(H[0]),F_2*-H[1],F_2*0]    #force is only acting in the y direction\n",
      "F3=[F_3/3.6*(G[0]-E[0]),F_3/3.6*(G[1]-E[1]),F_3/3.6*(G[2]-E[2])] #10/sqrt(13)=10/3.6\n",
      "\n",
      "#resultant force R\n",
      "\n",
      "#R=F1+F2+F3\n",
      "R=[F1[0]+F2[0]+F3[0],F1[1]+F2[1]+F3[1],F1[2]+F2[2]+F3[2]]\n",
      "\n",
      "#resultant force along axis AE\n",
      "\n",
      "r_ae=[E[0]-A[0],E[1]-A[1],E[2]-A[2]]\n",
      "\n",
      "r_ad=[D[0]-A[0],D[1]-A[1],D[2]-A[2]]\n",
      "\n",
      "#moments of force about A\n",
      "\n",
      "#M_ra=r_ae*F1+r_ae*F2+r_ae*F3\n",
      "\n",
      "M_ra1=[(r_ae[1]*F1[2]-r_ae[2]*F1[1]),(r_ae[0]*F1[2]-r_ae[2]*F1[0]),(r_ae[0]*F1[1]-r_ae[1]*F1[0])] #r_ae*F1\n",
      "M_ra2=[(r_ad[1]*F2[2]-r_ad[2]*F2[1]),(r_ad[0]*F2[2]-r_ad[2]*F2[0]),(r_ad[0]*F2[1]-r_ad[1]*F2[0])] #r_ae*F2\n",
      "M_ra3=[(r_ae[1]*F3[2]-r_ae[2]*F3[1]),(r_ae[0]*F3[2]-r_ae[2]*F3[0]),(r_ae[0]*F3[1]-r_ae[1]*F3[0])] #r_ae*F3\n",
      "\n",
      "M_ra=[M_ra1[0]+M_ra2[0]+M_ra3[0],M_ra1[1]+M_ra2[1]+M_ra3[1],M_ra1[2]+M_ra2[2]+M_ra3[2]]\n",
      "\n",
      "#Results\n",
      "\n",
      "print\"resultant force R\",round(R[0],2),\"i\",round(R[1],2),\"j +\",round(R[2],2),\"k\"\n",
      "print\"moments of all forces about A\",round(M_ra[0],3),\"i +\",round(M_ra[1]),\"j\",round(M_ra[2],3),\"k\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resultant force R 13.33 i -7.5 j + 5.56 k\n",
        "moments of all forces about A 20.556 i + 0.0 j -13.333 k\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-16,Page No:654"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialization\n",
      "\n",
      "F=20 #kN\n",
      "M_x=76 #kNm\n",
      "M_y=82 #kNm\n",
      "\n",
      "#Calculation\n",
      "\n",
      "#Force shifted to P by distance x\n",
      "x=M_x*F**-1\n",
      "\n",
      "#Force shifted to P by distance z\n",
      "z=M_y*F**-1\n",
      "\n",
      "#result\n",
      "\n",
      "print\"the force shifted to P by distance x\",round(x,2),\"m\"\n",
      "print\"the force shited to P by distance y\",round(z,2),\"m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the force shifted to P by distance x 3.8 m\n",
        "the force shited to P by distance y 4.1 m\n"
       ]
      }
     ],
     "prompt_number": 109
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-17,Page No:655"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#initialization\n",
      "\n",
      "A=[0,4.5,0]\n",
      "B=[2.8,0,0]\n",
      "C=[0,0,-2.4]\n",
      "D=[-2.6,0,1.8]\n",
      "\n",
      "#calculations\n",
      "\n",
      "#tension in cable AB\n",
      "x=(B[0]**2+A[1]**2)**0.5\n",
      "T_ab=[(B[0]-A[0])/x,(B[1]-A[1])/x,(B[2]-A[2])/x]\n",
      "\n",
      "#tension in cable AC\n",
      "y=(C[2]**2+A[1]**2)**0.5\n",
      "T_ac=[(C[0]-A[0])/y,(C[1]-A[1])/y,(C[2]-A[2])/y]\n",
      "\n",
      "#tension in cable AD\n",
      "z=(D[0]**2+D[2]**2+A[1]**2)**0.5\n",
      "T_ad=[[(D[0]-A[0])/z,(D[1]-A[1])/z,(D[2]-A[2])/z]]\n",
      "\n",
      "#weight acting vertically downwards \n",
      "W=[0*5000,1*5000,0*5000]\n",
      "\n",
      "#Solving using equations of equlibrium\n",
      "import math\n",
      "import numpy as np\n",
      "A=np.array([[0.528,-0.473,0],[0,-0.327,0.47],[0.85,0.818,0.88]])\n",
      "B=np.array([0,0,5000])\n",
      "C=np.linalg.solve(A,B)\n",
      "\n",
      "#result\n",
      "print \"T_AB =\",round(C[0],1),\"N\",\"T_AD =\",round(C[1]),\"N\",\"T_AC\",round(C[2],1),\"N\" \n",
      "#answer varies due to decimal accuracy in python\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "T_AB = 2043.7 N T_AD = 2281.0 N T_AC 1587.2 N\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-18,Page No:656"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of variables\n",
      "P=5 # kN\n",
      "Q=3 # kN\n",
      "C=5 # kNm # couple\n",
      "#  ref fig.20 # Notations have been assumed\n",
      "z1=1.5 # m\n",
      "z2=0.625 # m\n",
      "z3=0.5 # m\n",
      "x1=3.5 # m\n",
      "x2=0.625 # m\n",
      "# Calculations\n",
      "# sum M_x=0\n",
      "R_A=((P*z2)+(Q*z3)+C)*z1**-1 # kN\n",
      "# M_z=0\n",
      "R_C=((Q*x1)+(P*x2))*x1**-1 # kN\n",
      "# sum F_y=0\n",
      "R_B=P+Q-R_A-R_C # kN\n",
      "# Results\n",
      "\n",
      "print\"The reactions are: \",round(R_A,3),\"kN\",round(R_C,3),\"kN\",round(R_B,2),\"kN\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reactions are:  6.417 kN 3.893 kN -2.31 kN\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 26.26-19,Page No:657"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "\n",
      "# Initilization of variables\n",
      "F=2 # kN\n",
      "W=1 # kN\n",
      "# Co-ordinates as matrices\n",
      "A=[0,0,0]\n",
      "C=[0,0,1.2]\n",
      "B=[0,0,2.5]\n",
      "D=[-1,1,0]\n",
      "E=[1,1,0]\n",
      "F=[0,0,1]\n",
      "G=[0,0,2]\n",
      "# Force vector\n",
      "f=[0,-2,0]\n",
      "# Weight vector\n",
      "w=[0,-1,0]\n",
      "# Calculations\n",
      "# we have 5 unknowns: A_x,A_y,A_z,T_FE & T_GD\n",
      "# we define and solve eqn's 1,2,3,4&5 using matrix as,\n",
      "P=np.array([[1,0,0,0.58,-0.41],[0,1,0,0.58,0.41],[0,0,1,-0.58,-0.82],[0,0,0,0.58,0.82],[0,0,0,0.58,-0.82]])\n",
      "Q=np.array([0,3,0,6.25,0])\n",
      "X=np.linalg.solve(P,Q)\n",
      "\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The components of reaction at A are: A_x=\",round(X[0],2),\" kN \",\" A_y=\",round(X[1],2),\" kN \",\"and A_z=\",round(X[2],2),\" kN\"\n",
      "print\"The tensions in the cable are: T_FE=\",round(X[3],2),\" kN \",\"and T_GD=\",round(X[4],1), \"kN \"\n",
      "# The solution in the textbook is incorrect and yeilds singularity in matrix calculation.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The components of reaction at A are: A_x= -1.56  kN   A_y= -1.69  kN  and A_z= 6.25  kN\n",
        "The tensions in the cable are: T_FE= 5.39  kN  and T_GD= 3.8 kN \n"
       ]
      }
     ],
     "prompt_number": 11
    }
   ],
   "metadata": {}
  }
 ]
}