{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 2 Parallel Forces in a Plane"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.1 CFP"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The magnitude of resultant is 145.465646 Newton (N)\n",
      "The direction of resultant is 35.103909 degree\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#Initilization of variables\n",
    "P=50 #N\n",
    "Q=100 #N\n",
    "beta=150 #degree # angle between P & the horizontal\n",
    "#Calculations\n",
    "R=math.sqrt(P**2+Q**2-(2*P*Q*math.cos(beta*math.pi/180))) # using the Trignometric solution\n",
    "Alpha=math.degrees(math.asin((math.sin(beta*math.pi/180)*Q)/R))+15\n",
    "#Result\n",
    "print('The magnitude of resultant is %f Newton (N)'%R)\n",
    "print('The direction of resultant is %f degree'%Alpha)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.2 Addition of concurrent forces"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The magnitude of the resultant is 145.465646 N\n",
      "The ange of the resultant with x-axis is 35.103909 degree\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "P=50 #N\n",
    "Q=100 #N\n",
    "beta=15 #degree # angle between P& the horizontal\n",
    "theta=45 #degree # angle between the resultant (R) & the horizontal\n",
    "#Calculations\n",
    "Rx=P*math.cos(beta*math.pi/180)+Q*math.cos(theta*math.pi/180) #N\n",
    "Ry=P*math.sin(beta*math.pi/180)+Q*math.sin(theta*math.pi/180) #N\n",
    "R=math.sqrt((Rx**2)+(Ry**2)) #N\n",
    "alpha=math.degrees(math.atan(Ry/Rx)) #degree\n",
    "#Results\n",
    "print('The magnitude of the resultant is %f N'%R)\n",
    "print('The ange of the resultant with x-axis is %f degree'%alpha)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.4 Equilibrium equations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum force that can be applied is 4.015035 kN\n",
      "The direction of applied force is 75.000000  degree\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "Tac=3.5 #kN\n",
    "Tbc=3.5 #kN\n",
    "alpha=20 #degree #angle made by Tac with -ve X axis\n",
    "beta=50 #degree #angle made by Tbc with +ve X axis\n",
    "#Calculations\n",
    "theta=math.degrees(math.atan(((Tac*math.sin(alpha*math.pi/180))+(Tbc*math.sin(beta*math.pi/180)))/((Tac*math.cos(alpha*math.pi/180))-(Tbc*math.cos(beta*math.pi/180))))) #degree\n",
    "P=Tac*(math.cos(alpha*math.pi/180)-math.cos(beta*math.pi/180))/(math.cos(theta*math.pi/180)) #kN # from eq'n 1\n",
    "#Results\n",
    "print('The maximum force that can be applied is %f kN'%P)\n",
    "print('The direction of applied force is %f  degree'%theta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.8 Equilibrium of a body subjected to two forces"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The angle which the force should make with the horizontal to keep the edge AB of the body vertical 53.130102 degree\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "lAB=0.4 #m\n",
    "lBC=0.3 #m\n",
    "#Calculations\n",
    "alpha=math.degrees(math.atan(lAB/lBC)) #degree\n",
    "#Results\n",
    "print('The angle which the force should make with the horizontal to keep the edge AB of the body vertical %f degree'%alpha) #here alpha=theta"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.9 Equilibrium of a body subjected to three forces"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The axial force in the bar AC(by aw of concurrent forces) is 781.024968 N\n",
      "The axial force in the bar BC(by aw of concurrent forces) is 640.312424 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "F=1000 #N\n",
    "lAB=0.5 #m\n",
    "lDC=0.25 #m #length of the perpendicular drawn from point C to AB\n",
    "#Calculations\n",
    "lAC=math.sqrt((0.3)**2+(0.25)**2) #m\n",
    "lBC=math.sqrt((0.20)**2+(0.25)**2) #m\n",
    "Sac=(lAC*F)/(lAB) #N #by law of concurrent forces\n",
    "Sbc=(lBC*F)/(lAB) #N #by law of concurrent forces\n",
    "#Results\n",
    "print('The axial force in the bar AC(by aw of concurrent forces) is %f N'%Sac)\n",
    "print('The axial force in the bar BC(by aw of concurrent forces) is %f N'%Sbc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.10 Equilibrium of a body subjected to three forces"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The force F1 is 439.692621 N\n",
      "The force F2 is 326.351822 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "F3=500 #N\n",
    "alpha=60 #degree #angle made by F3 with F2\n",
    "beta=40 #degree #angle made by F1 with F3\n",
    "theta=80 #degree #angle made by F1 with F2\n",
    "#Calculations\n",
    "# Solving by using law of sines\n",
    "F1=(F3*math.sin(alpha*math.pi/180)/math.sin(theta*math.pi/180)) #N #by law of sines\n",
    "F2=(F3*math.sin(beta*math.pi/180)/math.sin(theta*math.pi/180)) #N #by law of sines\n",
    "#Resuts\n",
    "print('The force F1 is %f N'%F1)\n",
    "print('The force F2 is %f N'%F2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.11 Reaction at the hinge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The X component of reaction at A is 4330.127019 N\n",
      "The Y component of reaction at A is 1249.674658 N\n",
      "The reaction at support A is 4506.848871 N\n",
      "The reaction at support B is 1250.325342 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "P=5000 #N\n",
    "lAB=5 #m\n",
    "lOB=1.443 # m\n",
    "alpha=30 #degree #angle made by force P with the beam\n",
    "#Calculations\n",
    "theta=math.degrees(math.atan(lOB/lAB)) # degree # eq'n 1\n",
    "Xa=(P*math.cos(alpha*math.pi/180)) #N #using eq'n 4\n",
    "Ya=Xa*math.tan(theta*math.pi/180) #N # from eq'n 3 & 4\n",
    "Rb=P*math.sin(alpha*math.pi/180)-Ya # N  from eq'n 5# substuting value of Ya in eq'n 5\n",
    "Ra=math.sqrt((Xa**2)+(Ya**2)) #N\n",
    "#Results\n",
    "print('The X component of reaction at A is %f N'%Xa)\n",
    "print('The Y component of reaction at A is %f N'%Ya)\n",
    "print('The reaction at support A is %f N'%Ra)\n",
    "print('The reaction at support B is %f N'%Rb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.12 Reaction at the hinge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reaction at support A is 1250.000000  N\n",
      "The reaction at support B is 750.000000 N\n",
      "The angle that Rc makes with horizontal 53.130102 degree\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "W=1000 #N\n",
    "OD=0.4 #m\n",
    "AD=0.3 #m\n",
    "AO=0.5 #m #AO=sqrt((0.4)**2+(0.3)**2)\n",
    "#Calculations\n",
    "Ra=W*AO/OD #N # The answer of Ra in the textbook is incorrect\n",
    "Rc=W*AD/OD #N\n",
    "alpha=math.degrees(math.atan(OD/AD)) #degree\n",
    "#Results\n",
    "print('The reaction at support A is %f  N'%Ra)\n",
    "print('The reaction at support B is %f N'%Rc)\n",
    "print('The angle that Rc makes with horizontal %f degree'%alpha)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.13 Reaction at the hinge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tension in portion AB is 4328.394968 N\n",
      "Tension in portion BC is 2499.000000 N\n",
      "Tension in portion CD is 2499.000000 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "W=2500 #N #This load acts at point B and C.\n",
    "alpha=30 #degree # angle made by T1 with +ve y-axis & T2 with +ve x-axis\n",
    "#Calculations\n",
    "T2=W-(((math.cos(alpha*math.pi/180))**2/(math.sin(alpha*math.pi/180)))-(math.sin(alpha*math.pi/180))) # N # substuting eq'n 1 in 2\n",
    "T1=(T2*math.cos(30*math.pi/180))/(math.sin(30*math.pi/180)) #N # using eq'n 1\n",
    "T3=T2 #N # By equilibrium eq'n at point C(sumFx=0)\n",
    "#Results\n",
    "print('Tension in portion AB is %f N'%T1)\n",
    "print('Tension in portion BC is %f N'%T2)\n",
    "print('Tension in portion CD is %f N'%T3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.15 Equilibrium of a body"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The force P so that the wheel is just to roll over the block is 577.350269 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "d=0.6 #m #diameter of the wheel\n",
    "r=0.3 #m #radius of the wheel\n",
    "W=1000 #N #weight of the wheel\n",
    "h=0.15 #m #height of rectangular block\n",
    "#Calculations\n",
    "theta=math.atan((math.sqrt(h))/(math.sqrt(d-h)))\n",
    "P=(W*math.tan(theta)) #N # dividing eq'n 1 & 2\n",
    "#Resuts\n",
    "print('The force P so that the wheel is just to roll over the block is %f N'%P)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.16 Equilibrium of a Body"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The axial force in the bar AB is 1306.562965 N\n",
      "The axial force in the bar OB is 1000.000000 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "Soa=1000 #N (tension)\n",
    "alpha=45 #degree #where alpha=(360/8)\n",
    "theta=67.5 #degree #angle made by bar AO with AB &AH\n",
    "#Calcultions\n",
    "Sab=Soa*(math.sin(theta*math.pi/180)/math.sin(alpha*math.pi/180)) # N # Using law of sines\n",
    "Sah=Sab #N\n",
    "Sob=(Sab*math.sin((180-2*(theta))*math.pi/180))/math.sin(theta*math.pi/180) #N\n",
    "#Results\n",
    "print('The axial force in the bar AB is %f N'%Sab) #Compression\n",
    "print('The axial force in the bar OB is %f N'%Sob) #Tension"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.17 Equilibrium of a body"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reaction at A is 453.153894 N\n",
      "The reaction at B is 211.309131 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "W=500 #N #weight of cylinder\n",
    "alpha=25 #degree #angle made by OA with horizontal\n",
    "beta=65 #degree #angle made by OB with horizontal\n",
    "theta=90 #degree # theta=(alpha+beta)\n",
    "#Calculations\n",
    "Ra=(W*math.sin(beta*math.pi/180))/math.sin(theta*math.pi/180) #N #from equilibrium eq'n\n",
    "Rb=(W*math.sin(alpha*math.pi/180))/math.sin(theta*math.pi/180) #N #from equilibrium eqn's\n",
    "#Results\n",
    "print('The reaction at A is %f N'%Ra)\n",
    "print('The reaction at B is %f N'%Rb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.18 Equilibrium of a body"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reaction at point P is 268.383687 N\n",
      "The reaction at point L is 309.902788 N\n",
      "The reaction at point N is 1245.048606 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "Wa=1000 #N #weight of sphere A\n",
    "Wb=400 #N #weight of sphere B\n",
    "Ra=0.09 #m #radius of sphere A\n",
    "Rb=0.05 #m #radius of sphere B\n",
    "theta=33.86 #degree #angle made by Rq with Wb\n",
    "alpha=60 #degree #angle made by Rl with horizontal\n",
    "#Calculations\n",
    "Rq=Wb/math.cos(theta*math.pi/180) #N #using sum Fy=0 for sphere B\n",
    "Rp=Rq*math.sin(theta*math.pi/180) #N #using sum Fx=0 for sphere B\n",
    "Rl=(Rq*math.sin(theta*math.pi/180))/math.sin(alpha*math.pi/180) #N #using sum Fx=0 for sphere A\n",
    "Rn=((Wa)+(Rq*math.cos(theta*math.pi/180))-(Rl*math.cos(alpha*math.pi/180))) #N\n",
    "#Results\n",
    "print('The reaction at point P is %f N'%Rp)\n",
    "print('The reaction at point L is %f N'%Rl)\n",
    "print('The reaction at point N is %f N'%Rn)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.19 Equilibrium of a body"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The tension in the string is 66.143783 N\n",
      "The angle wich the string makes with the horizontal when the system is in equilibrium is 10.893395 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "P=50 #N\n",
    "Q=100 #N\n",
    "alpha=30 #degree #angle made by Rq with +ve Y-axis\n",
    "#Calculations\n",
    "theta=math.degrees(math.atan((P*1/math.tan(alpha*math.pi/180)-Q*math.tan(alpha*math.pi/180))/(P+Q))) #degree\n",
    "T=Q/(math.cos(theta*math.pi/180)*1/math.tan(alpha*math.pi/180)-math.sin(theta*math.pi/180)) #N\n",
    "#Results\n",
    "print('The tension in the string is %f N'%T)\n",
    "print('The angle wich the string makes with the horizontal when the system is in equilibrium is %f N'%theta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.20 Equilibrium of a body"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reaction between the cylinder A and the wall of the channel is 784.797079 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "theta1=50.5 #degree #is the angle made between BC & and BE\n",
    "theta2=36.87 #degree #is te angle ade between BA &BE \n",
    "g=9.81 #m/s**2\n",
    "Wa=15*g #N\n",
    "Wb=40*g #N\n",
    "Wc=20*g #N\n",
    "#Calculations\n",
    "R2=Wc/(math.sin(theta1*math.pi/180)) #N #from F.B.D of cylinder C(sum Fy=0)\n",
    "R4=(Wb+R2*math.sin(theta1*math.pi/180))/math.sin(theta2*math.pi/180) #N #from F.B.D of cylinder B(sum Fy=0)\n",
    "R6=R4*math.cos(theta2*math.pi/180) #N #from F.B.D of cylinder A(sum Fx=0)\n",
    "#Results\n",
    "print('The reaction between the cylinder A and the wall of the channel is %f N'%R6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.21 Equilibrium of a body"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reaction at D due to force of 1000 N acting at B is 500.000000 N\n"
     ]
    }
   ],
   "source": [
    "#Initilazation of variables\n",
    "F=1000 #N\n",
    "theta=30 #degree #angle made by the force with the beam AB\n",
    "Lab=3 #m\n",
    "Lae=2 #m\n",
    "Lce=1 #m\n",
    "#Calculations\n",
    "Re=(F*Lab*math.sin(theta*math.pi/180))/Lae #N #Taking moment at A\n",
    "Rd=(Re*Lce)/(Lab*math.sin(theta*math.pi/180)) #N #Taking moment about C\n",
    "#Results\n",
    "print('The reaction at D due to force of 1000 N acting at B is %f N'%Rd)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2.23 Equilibrium of a body"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The least force required to just turn the wheel over the block is 866.025404 N\n",
      "The angle wich should be made by Pmini with AC is 90.000000 degree\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "W=1000 #N\n",
    "r=0.30 #m #radius of the wheel\n",
    "h=0.15 #m #height of the obstacle\n",
    "#Calculations\n",
    "theta=math.degrees(math.asin(1)) #degree #P is mini when sin(theta)=1 from eq'n of P\n",
    "Pmini=(W*math.sqrt((2*r*h)-(h**2)))/(r*math.sin(theta*math.pi/180)) #N\n",
    "#Results\n",
    "print('The least force required to just turn the wheel over the block is %f N'%Pmini)\n",
    "print('The angle wich should be made by Pmini with AC is %f degree'%theta)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  },
  "widgets": {
   "state": {},
   "version": "1.1.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}