{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  Examples 5 -- Body Equilibrium\n",
    "\n",
    "Contents:\n",
    "- [A. Spool and sprocket](#A)\n",
    "- [B. Plane wing](#B)\n",
    "- [C. Antenna](#C)\n",
    "- [D. Device with pulleys](#D)             \n",
    "- [E. Clipboard clamp](#E)             \n",
    "- [F. Bar with self-aligning bearing (3D)](#F)               \n",
    "- [G. Bar with cable (3D)](#G)                           \n",
    "- [H. Plane wing (3D)](#H)              "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from numpy import *\n",
    "dtr = pi/180  # degree-to-radian conversion"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a name=\"A\"></a>\n",
    "\n",
    "## A. Spool and sprocket\n",
    "\n",
    "<img src=\"images/P5-26.png\" />"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "R_spool = 8.0      # in\n",
    "R_sproc = 5.0      # in\n",
    "CDx,CDy = 3.0,6.0  # in\n",
    "BDx = CDx\n",
    "BDy = 4.0          # in\n",
    "l_BA = 13.         # in\n",
    "Pdirx,Pdiry = -4.,-3.\n",
    "T_angle = 15*dtr   # radians below -x\n",
    "# part a\n",
    "P_max = 50.0       # lb\n",
    "# part b\n",
    "T_b = 80.0         # lb"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For part a, we balance two moments whose forces are already perpendicular to the radial direction:\n",
    "\n",
    "$$T_{max} R_{spool} = P_{max} L_{BA}$$\n",
    "\n",
    "For part b, moment sum in $z$-direction gives\n",
    "\n",
    "$$ T R_{spool} = |( R_{sproc} \\hat{u}_{BD}) \\times (F_{CD} \\hat{u}_{CD})| $$\n",
    "\n",
    "so\n",
    "\n",
    "$$ F_{CD} = \\frac{ T R_{spool}}{  R_{sproc} \\left |\\hat{u}_{BD} \\times  \\hat{u}_{CD}  \\right |} $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part a\n",
      "    T = 81.25 lb\n",
      "    Bx= 118.481473386 lb\n",
      "    By= 51.0290474146 lb\n",
      "part b\n",
      "    FCD= -143.10835056 lb\n",
      "     Bx= 13.2740661031 lb\n",
      "     By= 148.705523608 lb\n"
     ]
    }
   ],
   "source": [
    "# part a\n",
    "T_max = P_max*l_BA/R_spool\n",
    "P = P_max * array((Pdirx,Pdiry)) / sqrt(Pdirx**2+Pdiry**2)\n",
    "T = T_max * array((-cos(T_angle),-sin(T_angle)))\n",
    "Bx = -P[0] - T[0]\n",
    "By = -P[1] - T[1]\n",
    "print ('part a')\n",
    "print ('    T =',T_max,'lb')\n",
    "print ('    Bx=',Bx,'lb')\n",
    "print ('    By=',By,'lb')\n",
    "# part b\n",
    "T = T_b * array((-cos(T_angle),-sin(T_angle)))\n",
    "uCD = array((CDx,-CDy)) / sqrt(CDx**2+CDy**2)\n",
    "uBD = array((BDx, BDy)) / sqrt(BDx**2+BDy**2)\n",
    "FCD_mag = T_b * R_spool / ( R_sproc*abs(cross(uBD,uCD)))\n",
    "FCD = FCD_mag * uCD\n",
    "Bx = -FCD[0] - T[0]\n",
    "By = -FCD[1] - T[1]\n",
    "print ('part b')\n",
    "print ('    FCD=',-FCD_mag,'lb')\n",
    "print ('     Bx=',Bx,'lb')\n",
    "print ('     By=',By,'lb')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a name=\"B\"></a>\n",
    "\n",
    "## B. Plane wing\n",
    "\n",
    "\n",
    "<img src=\"images/P5-27.png\" />"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "M = 1150.      # kg\n",
    "M_wing = 240.  # kg\n",
    "AEy = 1.4      # m\n",
    "ABx = 3.0      # m\n",
    "BCx = 0.8      # m\n",
    "CDx = 2.5      # m\n",
    "g = 9.81       # N/kg"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"images/P5-27a.png\" width=\"300\" height=\"300\"  align=\"right\" />\n",
    "\n",
    "For part b, consider the free-body diagram and sum moments about point A:\n",
    "\n",
    "$$  - \\left | \\vec{r}_{AB} \\right | M_{wing}g - \\left |\\vec{r}_{AB} \\times \\left (T_{BE} \\hat{u}_{BE}  \\right )  \\right | + \\left | \\vec{r}_{AC} \\right | P = 0 $$\n",
    "\n",
    "So\n",
    "\n",
    "$$ T_{BE} = \\frac{\\left | \\vec{r}_{AC} \\right | P- \\left | \\vec{r}_{AB} \\right | M_{wing}g}{\\left |\\vec{r}_{AB}  \\hat{\\imath} \\times  \\hat{u}_{BE}   \\right |}    $$\n",
    "\n",
    "$$T_{BE} = \\frac{\\left | \\vec{r}_{AC} \\right | P- \\left | \\vec{r}_{AB} \\right | M_{wing}g}{\\left |\\vec{r}_{AB}    \\right | \\frac{\\left |\\vec{r}_{AE}\\right |}{\\left |\\vec{r}_{BE}  \\right |}  }   $$\n",
    "\n",
    "$$T_{BE} = \\left (\\frac{\\left |\\vec{r}_{AC}\\right |}{\\left |\\vec{r}_{AB}  \\right |} P-  M_{wing}g  \\right ) \\frac{\\left |\\vec{r}_{BE}\\right |}{\\left |\\vec{r}_{AE}  \\right |}$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part a\n",
      "    P= 5640.75 N\n",
      "part b\n",
      "    TBE= 11328.2446259 N\n",
      "     Ax= 10265.4642857 N\n",
      "     Ay= 1504.2 N\n"
     ]
    }
   ],
   "source": [
    "# part a\n",
    "P = 0.5 * M*g\n",
    "print ('part a')\n",
    "print ('    P=',P,'N')\n",
    "# part b\n",
    "TBE_tension = ( (ABx+BCx)/ABx * P - M_wing*g ) * sqrt(ABx**2+AEy**2)/AEy\n",
    "uBE = array((-ABx,-AEy))/sqrt(ABx**2+AEy**2)\n",
    "TBE = TBE_tension * uBE\n",
    "FAx = -TBE[0]\n",
    "FAy = -TBE[1] + M_wing*g - P\n",
    "print ('part b')\n",
    "print ('    TBE=',TBE_tension,'N')\n",
    "print ('     Ax=',FAx,'N')\n",
    "print ('     Ay=',FAy,'N')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a name=\"C\"></a>\n",
    "\n",
    "## C. Antenna\n",
    "\n",
    "<img src=\"images/P5-41.png\" />"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "Wa, Wg = 327., 123.  # lb\n",
    "F_load = 92.         # lb\n",
    "Y = 29.*12      # in\n",
    "X1,X2 = 5.,6.   # in\n",
    "R = 20.         # in (gear radius)\n",
    "Q = 16*dtr      # radians"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "<img src=\"images/P5-41a.png\" width=\"200\" height=\"300\"  align=\"right\" />\n",
    "\n",
    "\n",
    "Define positive $G$ to be in lower-right direction (because of arrow in answer box).\n",
    "\n",
    "$$\\sum F_x = A_x + G \\cos \\theta - w = 0$$\n",
    "\n",
    "$$\\sum F_y = -W_a - W_g + A_y - G \\sin \\theta = 0$$\n",
    "\n",
    "$$\\sum M_A = R G + X_1 W_g - X_2 W_a + Yw = 0$$\n",
    "\n",
    "Solving moment equation for $G$, then force sums for $A_x$ and $A_y$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "answer:\n",
      "    G = -1533.45 lb\n",
      "    Ay= 27.3238967224 lb\n",
      "    Ax= 1566.04674764 lb\n"
     ]
    }
   ],
   "source": [
    "w = F_load\n",
    "G = -(X1*Wg - X2*Wa + Y*w)/R\n",
    "Ax = w - G*cos(Q) \n",
    "Ay = Wa + Wg + G*sin(Q)\n",
    "print ('answer:')\n",
    "print ('    G =',G,'lb')\n",
    "print ('    Ay=',Ay,'lb')\n",
    "print ('    Ax=',Ax,'lb')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "checked; works."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note the direction for $G$ in the answer box defines the positive direction for that answer."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a name=\"D\"></a>\n",
    "\n",
    "## D. Device with pulleys\n",
    "\n",
    "<img src=\"images/P5-56.png\" />"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "R = 4.                       # in  (pulley radii)\n",
    "W = 40.                      # lb\n",
    "X1,X2,X3 = 12.,26.,12.       # in (left to right)\n",
    "Y1,Y2,Y3,Y4 = 17.,5.,10.,5.  # in (bottom to top)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "\n",
    "<img src=\"images/P5-56a.jpg\" width=\"400\" height=\"300\"/>\n",
    "\n",
    "First note that $T=W/2$. Also, we may shift forces to pulley bearings as you can verify with an FBD of the pulley at *C*.\n",
    "\n",
    "Sum of moments about $A$:\n",
    "\n",
    "$$\\sum M_A = B_y X_1 -B_X Y_2 +T(Y_2+Y_3)-T(X_1+X_2)-T(X_1+X_2+X_3)=0$$\n",
    "\n",
    "where $B_x = \\frac{X_1}{Z}B$ and $B_y = \\frac{Y_1+Y_2}{Z}B$\n",
    "where $Z = \\sqrt{X_1^2+(Y_1+Y_2)^2}$.\n",
    "\n",
    "Solve for $B$:\n",
    "\n",
    "$$B = T(2X_1+2X_2+X_3-Y_2-Y_3)\\frac{Z}{X_1Y_1} $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "answer:\n",
      "    Ax= -65.8823529412 lb\n",
      "    Ay= -117.450980392 lb\n"
     ]
    }
   ],
   "source": [
    "T=W/2\n",
    "Z = sqrt(X1**2+(Y1+Y2)**2)\n",
    "B = T*( 2*X1 + 2*X2 + X3 - Y2 - Y3) * Z/(X1*Y1)\n",
    "# force sum:\n",
    "Ax = T - B*X1/Z\n",
    "Ay = 2*T - B*(Y1+Y2)/Z\n",
    "print ('answer:')\n",
    "print ('    Ax=',Ax,'lb')\n",
    "print ('    Ay=',Ay,'lb')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a name=\"E\"></a>\n",
    "\n",
    "## E. Clipboard clamp\n",
    "\n",
    "<img src=\"images/P5-70.png\" />"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "kt = 3.0         # in.lb/rad\n",
    "X1,X2 = 2.1,0.8  # in (left to right)\n",
    "Ay = 4.0         # lb\n",
    "# vertical distances not required"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Moment sum about C when $P=0$:\n",
    "\n",
    "$$\\sum M_C = k_t \\theta - X_1 Ay = 0$$\n",
    "\n",
    "Moment sum about C when $A_y=0$:\n",
    "\n",
    "$$\\sum M_C = k_t \\theta - X_2 P = 0$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "answer:\n",
      "    P= 10.5 lb\n",
      "    Q= 0.445633840657307 turns\n"
     ]
    }
   ],
   "source": [
    "Q = X1*Ay/kt\n",
    "Q_turns = Q/(2*pi)\n",
    "P = kt*Q/X2\n",
    "print ('answer:')\n",
    "print ('    P=',P,'lb')\n",
    "print ('    Q=',Q_turns,'turns')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "<a name=\"F\"></a>\n",
    "\n",
    "## F. Bar with self-aligning bearing (3D)\n",
    "\n",
    "<img src=\"images/P5-105.png\" />"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X = 4.0        # ft\n",
    "Y1,Y2 = 4.,4.  # ft\n",
    "ZE,ZF = 2.,4.  # ft\n",
    "F = 102.       # lb"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Force sum:\n",
    "\n",
    "$\\sum \\vec{F} = \\vec{A} + T_{BF} (-\\tfrac{1}{\\sqrt{2}}\\hat{\\imath}+\\tfrac{1}{\\sqrt{2}}\\hat{k}) -F\\hat{k} +(E_x\\hat{\\imath}+E_z\\hat{k})=0$\n",
    "\n",
    "x-direction: $A_x - T_{BF} \\tfrac{1}{\\sqrt{2}} + E_x=0$\n",
    "\n",
    "y-direction: $A_y =0$\n",
    "\n",
    "z-direction: $A_z + T_{BF} \\tfrac{1}{\\sqrt{2}} -F +E_z=0$\n",
    "\n",
    "Moment sum about *A*:\n",
    "\n",
    "$\\sum \\vec{M}_A = XT_{BF}\\tfrac{1}{\\sqrt{2}}(-\\hat{\\jmath}) + (X\\hat{\\imath}+Y_1\\hat{\\jmath})\\times(-F\\hat{k})+(X\\hat{\\imath}+(Y_1+Y_2)\\hat{\\jmath}+Z_E\\hat{k})\\times(E_x\\hat{\\imath}+E_z\\hat{k})=0$\n",
    "\n",
    "$\\sum \\vec{M}_A = -\\frac{XT_{BF}}{\\sqrt{2}}\\hat{\\jmath} + XF\\hat{\\jmath} - Y_1F\\hat{\\imath}+(Y_1+Y_2)E_z\\hat{\\imath}+ (Z_EE_x-XE_z) \\hat{\\jmath} - (Y_1+Y_2)E_x\\hat{k}=0\n",
    "$\n",
    "\n",
    "x-direction: $-Y_1F+(Y_1+Y_2)E_z =0$\n",
    "\n",
    "y-direction: $-\\frac{XT_{BF}}{\\sqrt{2}} + XF +Z_EE_x-XE_z =0$\n",
    "\n",
    "z-direction: $-(Y_1+Y_2)E_x=0$\n",
    "\n",
    "So $A_y=0$ and $E_x=0$ and $E_z=\\frac{Y_1F}{Y_1+Y_2}$. \n",
    "\n",
    "Then $T_{BF}=-(XE_z-XF)\\sqrt{2}/X$. \n",
    "\n",
    "And $A_x = T_{BF} \\tfrac{1}{\\sqrt{2}}$. \n",
    "\n",
    "And $A_z = -T_{BF} \\tfrac{1}{\\sqrt{2}} +F -E_z$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "answer:\n",
      "    Ax= 51.0 lb\n",
      "    Ay= 0.0 lb\n",
      "    Az= 7.1054273576e-15 lb\n",
      "    TBF= 72.124891681 lb\n",
      "    Ex= 0.0 lb\n",
      "    Ez= 51.0 lb\n"
     ]
    }
   ],
   "source": [
    "Ay=Ex=0.\n",
    "Ez = Y1*F/(Y1+Y2)\n",
    "TBF = -(X*Ez-X*F)*sqrt(2)/X\n",
    "Ax = TBF/sqrt(2)\n",
    "Az = -TBF/sqrt(2)+F-Ez\n",
    "print ('answer:')\n",
    "print ('    Ax=',Ax,'lb')\n",
    "print ('    Ay=',Ay,'lb')\n",
    "print ('    Az=',Az,'lb')\n",
    "print ('    TBF=',TBF,'lb')\n",
    "print ('    Ex=',Ex,'lb')\n",
    "print ('    Ez=',Ez,'lb')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a name=\"G\"></a>\n",
    "\n",
    "## G. Bar with cable (3D)\n",
    "\n",
    "\n",
    "<img src=\"images/P5-106.png\" />"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "F = 27.          # lb\n",
    "X,Y,Z = 8.,8.,4. # in."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Force sum:\n",
    "\n",
    "$\\sum \\vec{F} = A_x \\hat{\\imath}+A_z\\hat{k}-F\\hat{\\jmath}+T_{CD}\\hat{u}_{CD}=0$\n",
    "\n",
    "x-direction: $A_x -\\tfrac{X}{\\alpha}T_{CD}=0$\n",
    "\n",
    "y-direction: $-F +\\tfrac{Y}{\\alpha}T_{CD}=0$\n",
    "\n",
    "z-direction: $A_z -\\tfrac{Z}{\\alpha}T_{CD}=0$\n",
    "\n",
    "Let $\\alpha = \\sqrt{X^2+Y^2+Z^2}$.\n",
    "\n",
    "Moment sum about *A*:\n",
    "\n",
    "$\\sum \\vec{M}_A = M_{Ax}\\hat{\\imath} +M_{Az}\\hat{k} -XF\\hat{k}+T_{CD}\\vec{r}_{AC}\\times\\hat{u}_{CD}=0$\n",
    "\n",
    "$\\sum \\vec{M}_A = M_{Ax}\\hat{\\imath} +M_{Az}\\hat{k} -XF\\hat{k}+\\frac{T_{CD}}{\\alpha}\\left ( -ZY\\hat{\\imath}+XY\\hat{k} \\right ) =0$\n",
    "\n",
    "x-direction: $M_{Ax} -ZY\\frac{T_{CD}}{\\alpha} =0$\n",
    "\n",
    "y-direction: (no equation)\n",
    "\n",
    "z-direction: $M_{Az} -XF+\\frac{T_{CD}}{\\alpha} XY =0$\n",
    "\n",
    "The force sum in the *y* direction yields $T_{CD}$, then the rest of the equations are just in terms of $T_{CD}$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "answer:\n",
      "    TCD= 40.5 lb\n",
      "     Ax= 27.0 lb\n",
      "     Az= 13.5 lb\n",
      "    MAx= 108.0 in.lb\n",
      "    MAz= 0.0 in.lb\n"
     ]
    }
   ],
   "source": [
    "alpha = sqrt(X**2+Y**2+Z**2)\n",
    "TCD = alpha*F/Y\n",
    "Ax = TCD*X/alpha\n",
    "Az = TCD*Z/alpha\n",
    "MAx = Z*Y*TCD/alpha\n",
    "MAz = X*F - X*Y*TCD/alpha\n",
    "print ('answer:')\n",
    "print ('    TCD=',TCD,'lb')\n",
    "print ('     Ax=',Ax,'lb')\n",
    "print ('     Az=',Az,'lb')\n",
    "print ('    MAx=',MAx,'in.lb')\n",
    "print ('    MAz=',MAz,'in.lb')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a name=\"H\"></a>\n",
    "\n",
    "## H. Plane wing (3D)\n",
    "\n",
    "<img src=\"images/P5-115.png\" />"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "M = 800.         # kg\n",
    "Mwing = 170.     # kg\n",
    "XA,XF = 0.3,0.1  # m\n",
    "YB,YBC = 2.2,0.7 # m\n",
    "ZE = 1.3         # m\n",
    "f = 0.1          # fraction of P that is Q"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"images/P5-115a.png\" width=\"600\" height=\"300\"/>\n",
    "\n",
    "Let $\\alpha=\\sqrt{Y_B^2+Z_E^2}$.\n",
    "\n",
    "Force sum:\n",
    "\n",
    "x-direction: $A_x-Q=0$\n",
    "\n",
    "y-direction: $A_y+F_y-T_{BE}\\frac{Y_B}{\\alpha}=0$\n",
    "\n",
    "z-direction: $A_z+F_z-T_{BE}\\frac{Z_E}{\\alpha}+P-M_wg=0 $\n",
    "\n",
    "Moment sum about *F*:\n",
    "\n",
    "$\\sum \\vec{M}_F = -(X_A+X_F)A_z\\hat{\\jmath}+(X_A+X_F)A_y\\hat{k}+(X_F\\hat{\\imath}+Y_B\\hat{\\jmath}) \\times \\left [-T_{BE}\\frac{Y_B}{\\alpha}\\hat{\\jmath}+\\left (-T_{BE}\\frac{Z_E}{\\alpha}-M_wg  \\right )\\hat{k}  \\right ]+Y_CQ\\hat{k}+Y_CP\\hat{\\imath}=0$\n",
    "\n",
    "$\\sum \\vec{M}_F = -(X_A+X_F)A_z\\hat{\\jmath}+(X_A+X_F)A_y\\hat{k}+\\left [Y_B\\left (-\\frac{T_{BE}Z_E}{\\alpha}-M_wg  \\right )\\hat{\\imath}-X_F\\left (-\\frac{T_{BE}Z_E}{\\alpha}-M_wg  \\right )\\hat{\\jmath}-\\frac{T_{BE}X_FY_B}{\\alpha}\\hat{k}  \\right ]+Y_CQ\\hat{k}+Y_CP\\hat{\\imath}=0$\n",
    "\n",
    "x-direction: $Y_B\\left (-\\frac{T_{BE}Z_E}{\\alpha} -M_wg\\right )+Y_CP=0$\n",
    "\n",
    "y-direction: $-(X_A+X_F)A_z-X_F\\left (-\\frac{T_{BE}Z_E}{\\alpha}-M_wg\\right )=0$\n",
    "\n",
    "z-direction: $(X_A+X_F)A_y-\\frac{T_{BE}}{\\alpha}X_FY_B+Y_CQ=0$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "answer:\n",
      "      P= 3924.0 N\n",
      "    TBE= 6889.41126646 N\n",
      "     Fy= 7293.35769231 N\n",
      "     Fz= -44.5909090909 N\n",
      "     Ax= 392.40000000000003 N\n",
      "     Ay= -1362.08076923 N\n",
      "     Az= 1293.13636364 N\n"
     ]
    }
   ],
   "source": [
    "# part a\n",
    "g = 9.81 # N/kg\n",
    "P = 0.5*M*g\n",
    "# part b\n",
    "Q = f*P\n",
    "Ax = Q\n",
    "alpha = sqrt(YB**2+ZE**2)\n",
    "YC = YB+YBC\n",
    "TBE = -(-YC*P/YB+Mwing*g)*alpha/ZE\n",
    "tmp = XF*(-TBE*ZE/alpha - Mwing*g)\n",
    "Az = -tmp/(XA+XF)\n",
    "Ay = -(-TBE*XF*YB/alpha+YC*Q)/(XA+XF)\n",
    "Fy = TBE*YB/alpha - Ay\n",
    "Fz = Mwing*g - P - Az + TBE*ZE/alpha\n",
    "print ('answer:')\n",
    "print ('      P=',P,'N')\n",
    "print ('    TBE=',TBE,'N')\n",
    "print ('     Fy=',Fy,'N')\n",
    "print ('     Fz=',Fz,'N')\n",
    "print ('     Ax=',Ax,'N')\n",
    "print ('     Ay=',Ay,'N')\n",
    "print ('     Az=',Az,'N')"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "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.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
