summaryrefslogtreecommitdiff
path: root/Engineering_Mechanics_by_A._K._Tayal/Chapter_26_APPENDIX.ipynb
blob: 0bfaddaeec78ca8b7b3a4335e5e7bc30178f0d8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 26 Appendix"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.1 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Position vector is -5.000000i+2.000000j+14.000000k\n",
      "The value of r is 15.000000*l i + 15.000000*m j + 15.000000*n k\n",
      "The unit vector in the direction of r is -0.333333i+0.133333j+0.933333k\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#Initilization of variables\n",
    "P=[-5,2,14] #Point co-ordinates\n",
    "#Calculations\n",
    "r=math.sqrt(P[0]**2+P[1]**2+P[2]**2) #Magnitude of the poistion vector\n",
    "#Direction cosines\n",
    "l=P[0]/r \n",
    "m=P[1]/r\n",
    "n=P[2]/r\n",
    "#Unit Vector calculations\n",
    "r_unit=[]\n",
    "r_unit[:]=[P[i]/r for i in range(0,3)]\n",
    "#Results\n",
    "print(\"The Position vector is %fi+%fj+%fk\"%(P[0],P[1],P[2]))\n",
    "print('The value of r is %f*l i + %f*m j + %f*n k'%(r,r,r))\n",
    "print(\"The unit vector in the direction of r is %fi+%fj+%fk\"%(r_unit[0],r_unit[1],r_unit[2]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.2 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The force in vector notation is -1.097643i-9.878783j-1.097643k\n",
      "Thetax=96.301726 degrees,Thetay=171.069858 degrees,Thetaz=96.301726 degrees\n"
     ]
    }
   ],
   "source": [
    "#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=math.sqrt(d_x**2+d_y**2+d_z**2)\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=math.degrees(math.acos(l)) #degrees\n",
    "theta_y=math.degrees(math.acos(m)) #degrees\n",
    "theta_z=math.degrees(math.acos(n)) #degrees\n",
    "\n",
    "#Result\n",
    "print(\"The force in vector notation is %fi%fj%fk\"%(Fx,Fy,Fz))\n",
    "print(\"Thetax=%f degrees,Thetay=%f degrees,Thetaz=%f degrees\"%(theta_x,theta_y,theta_z))  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.3 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The force vector is -1059.997880i+2119.995760j+794.998410k N\n",
      "The angles are thetax=115.087329,thetay=32.005383 and thetaz=71.458022 degrees\n"
     ]
    }
   ],
   "source": [
    "#initiliation of variables\n",
    "T=2500 #N\n",
    "#Co-ordinates\n",
    "Q=[40,0,-30]\n",
    "P=[0,80,0]\n",
    "\n",
    "#Calculations\n",
    "mag_QP=math.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=[]\n",
    "F[:]=[(T/mag_QP)*QP[i] for i in range(0,3)] #N\n",
    "thetax=(math.acos(F[0]/T)*180/math.pi) #degrees\n",
    "thetay=(math.acos(F[1]/T)*180/math.pi) #degrees\n",
    "thetaz=(math.acos(F[2]/T)*180/math.pi) #degrees\n",
    "\n",
    "#Result\n",
    "print(\"The force vector is %fi+%fj+%fk N\"%(F[0],F[1],F[2]))\n",
    "#Answer in the textbook is printed as 1600 which is incorrect\n",
    "print(\"The angles are thetax=%f,thetay=%f and thetaz=%f degrees\"%(thetax,thetay,thetaz))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.4 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The unit vector is 0.635999i-0.212000j+0.741999k\n"
     ]
    }
   ],
   "source": [
    "#initilization of variables\n",
    "A=[2,-1,1]\n",
    "B=[1,1,2]\n",
    "C=[3,-2,4]\n",
    "#Calculations\n",
    "R=[A[0]+B[0]+C[0],A[1]+B[1]+C[1],A[2]+B[2]+C[2]] #Resultant\n",
    "mag=math.sqrt(R[0]**2+R[1]**2+R[2]**2)\n",
    "#Unit vector\n",
    "U=[]\n",
    "U[:]=[R[i]/mag for i in range(0,3)] \n",
    "#Result\n",
    "print(\"The unit vector is %fi%fj+%fk\"%(U[0],U[1],U[2]))\n",
    "#Answer for (k) is incorrect in the textbook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.5 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The product of both the vectors is -7.000000\n",
      "The angle between them is 101.309932 degrees\n"
     ]
    }
   ],
   "source": [
    "#initilization of variables\n",
    "A=[2,-6,-3]\n",
    "B=[4,3,-1] \n",
    "#Calculations\n",
    "AdotB=A[0]*B[0]+A[1]*B[1]+A[2]*B[2] \n",
    "magA=math.sqrt(A[0]**2+A[1]**2+A[2]**2) \n",
    "magB=math.sqrt(B[0]**2+B[1]**2+B[2]**2)\n",
    "theta=math.degrees(math.acos(AdotB/(magA*magB))) #degrees\n",
    "\n",
    "#Result\n",
    "print(\"The product of both the vectors is %f\"%AdotB)\n",
    "print(\"The angle between them is %f degrees\"%theta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.6 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of A.costheta is 1.000000\n"
     ]
    }
   ],
   "source": [
    "#initilization of variables\n",
    "A=[4,-3,1]\n",
    "P=[2,3,-1]\n",
    "Q=[-2,-4,3]\n",
    "#Calculations\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=math.sqrt(B[0]**2+B[1]**2+B[2]**2)\n",
    "Acostheta=AdotB/magB\n",
    "#Result\n",
    "print(\"The value of A.costheta is %f\"%Acostheta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.7 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The work done is 135 units\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "#Initilization of variables\n",
    "F=np.array([5,10,-15])\n",
    "a=np.array([1,0,3])\n",
    "b=np.array([3,-1,-6])\n",
    "#Calculations\n",
    "d=b-a\n",
    "work=F*d\n",
    "Work=work[0]+work[1]+work[2]\n",
    "#Result\n",
    "print(\"The work done is %d units\"%Work)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.8 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The cross prcoduct of the two vectors is 15.000000i -10.000000j+30.000000k\n",
      "The angle between the two is 78.690068 degrees\n"
     ]
    }
   ],
   "source": [
    "#initilization of variables\n",
    "A=[2,-6,-3]\n",
    "B=[4,3,-1]\n",
    "#Calculations\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=math.sqrt(AcrossB[0]**2+AcrossB[1]**2+AcrossB[2]**2)\n",
    "n=[AcrossB[i]/mag for i in range(0,3)]\n",
    "magA=math.sqrt(A[0]**2+A[1]**2+A[2]**2)\n",
    "magB=math.sqrt(B[0]**2+B[1]**2+B[2]**2)\n",
    "theta=math.degrees(math.asin(mag/(magA*magB)))\n",
    "#Result\n",
    "print(\"The cross prcoduct of the two vectors is %fi %fj+%fk\"%(AcrossB[0],AcrossB[1],AcrossB[2])) #the answer for j is wrong in textbook\n",
    "print(\"The angle between the two is %f degrees\"%theta)\n",
    "# Only 1 value for theta has been solved"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.9 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The vector notation of velocity is 10.474459i -6.110101j -0.436436k\n",
      "The magnitude of the Velocity Vector is 12.134171\n"
     ]
    }
   ],
   "source": [
    "# Initilization of Variable \n",
    "# Points As martices\n",
    "A=[0,1,2]\n",
    "B=[1,3,-2]\n",
    "P=[3,6,4]\n",
    "a_s=2 # Angular speed in rad/s\n",
    "\n",
    "# Calculations\n",
    "C=(B[0]-A[0],B[1]-A[1],B[2]-A[2])\n",
    "magC=(C[0]**2+C[1]**2+C[2]**2)**0.5 # Magnitude of the Vector C \n",
    "# Unit vector\n",
    "C_unit=(C[0]/magC,C[1]/magC,C[2]/magC) # Unit vector\n",
    "# Position Vector\n",
    "r=(P[0]-A[0],P[1]-A[1],P[2]-A[2])\n",
    "# Velocity Vector\n",
    "# Calculating the cross product as,\n",
    "V=(C[1]*r[2]-C[2]*r[1],C[2]*r[0]-C[0]*r[2],C[0]*r[1]-C[1]*r[0])\n",
    "# Vector notation\n",
    "V_n=[]\n",
    "V_n[:]=[(a_s/magC)*V[i] for i in range(0,3)]\n",
    "# Velocity Magnitude\n",
    "magV=math.sqrt(V[0]**2+V[1]**2+V[2]**2)\n",
    "v=(a_s/magC)*magV\n",
    "# Result\n",
    "print(\"The vector notation of velocity is %fi %fj %fk\"%(V_n[0],V_n[1],V_n[2]))\n",
    "print(\"The magnitude of the Velocity Vector is %f\"%v)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.10 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Moment about point O is 9.000000i -1.000000j+32.000000k\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "# Points as matrices\n",
    "O=[-2,3,5]\n",
    "P=[1,-2,4]\n",
    "Q=[5,2,3]\n",
    "F=[4,4,-1] # Force vector\n",
    "# Calculations\n",
    "# Positon vector , r_2 gives the same answer as r_1\n",
    "r_1=(P[0]-O[0],P[1]-O[1],P[2]-O[2])\n",
    "# Moment\n",
    "# Calculating the cross product\n",
    "M=(r_1[1]*F[2]-r_1[2]*F[1],r_1[2]*F[0]-r_1[0]*F[2],r_1[0]*F[1]-r_1[1]*F[0])\n",
    "# Results\n",
    "print('The Moment about point O is %fi %fj+%fk'%(M[0],M[1],M[2]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.11 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The moment of the force is 2.000000i -7.000000j -2.000000k\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "# Points as matrices\n",
    "P=[1,-1,2] # Point where force is applied\n",
    "O=[2,-1,3] # point where moment is to be found\n",
    "F=[3,2,-4] # Force vector\n",
    "# Calculations\n",
    "# Position vector of point P wrt O\n",
    "r=(P[0]-O[0],P[1]-O[1],P[2]-O[2])\n",
    "# Moment\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",
    "# Resuts\n",
    "print('The moment of the force is %fi %fj %fk'%(M[0],M[1],M[2]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.12 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The moment is -68.000000i + 102.000000j + 0.000000 k\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "f=22 # N \n",
    "# Points as matrices\n",
    "A=[4,-1,7]\n",
    "O=[1,-3,2]\n",
    "V=[9,6,-2] # Given vector\n",
    "# Calculations\n",
    "# Unit vector in the direction of the vector\n",
    "denom=math.sqrt(V[0]**2+V[1]**2+V[2]**2)\n",
    "v=[V[i]/denom for i in range(0,3)]\n",
    "# Force\n",
    "F=[f*v[i] for i in range(0,3)]\n",
    "# Position vector of point A wrt O\n",
    "r=(A[0]-O[0],A[1]-O[1],A[2]-O[2])\n",
    "# Moment\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",
    "# Results\n",
    "print('The moment is %fi + %fj + %f k'%(M[0],M[1],M[2]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.13 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The components of the force is along u=3.301270 N,along v=-94.282032 N,along w=30.000000 N\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "# Force Vector\n",
    "F=[50,-80,30]\n",
    "# from fig.13\n",
    "theta1=30 # angles by which the axis is rotated [ all in degrees]\n",
    "theta2=60\n",
    "theta3=90\n",
    "theta4=120\n",
    "theta5=0\n",
    "# Calculations\n",
    "# Unit vector in u-direction\n",
    "u_unit=(1*math.cos(theta1*math.pi/180),1*math.cos(theta2*math.pi/180),1*math.cos(theta3*math.pi/180))\n",
    "# Unit vector in v-direction\n",
    "v_unit=(1*math.cos(theta4*math.pi/180),1*math.cos(theta1*math.pi/180),1*math.cos(theta3*math.pi/180))\n",
    "# Unit vector in w-direction\n",
    "w_unit=(1*math.cos(theta3*math.pi/180),1*math.cos(theta3*math.pi/180),1*math.cos(theta5*math.pi/180))\n",
    "# Components of force\n",
    "# finding the dot product as\n",
    "u=F[0]*u_unit[0]+F[1]*u_unit[1]+F[2]*u_unit[2] # N\n",
    "v=F[0]*v_unit[0]+F[1]*v_unit[1]+F[2]*v_unit[2] # N\n",
    "w=F[0]*w_unit[0]+F[1]*w_unit[1]+F[2]*w_unit[2] # N\n",
    "# Results\n",
    "print('The components of the force is along u=%f N,along v=%f N,along w=%f N'%(u,v,w))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.14 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The moment of the force about point E is 0.000000i - 44.721360j + 22.360680k N.m\n",
      "The moment of force about axis AE is -44.721360 N.m\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "f=100 # N # magnitude of force\n",
    "# Co-ordinates of corners of the box as matrices\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",
    "# Calculations\n",
    "# Force vector\n",
    "Fmag=f/math.sqrt((F[0]-C[0])**2+(F[1]-C[1])**2+(F[2]-C[2])**2)\n",
    "F=[Fmag*(F[i]-C[i]) for i in range(0,3)]\n",
    "# Position vector\n",
    "r_EC=(C[0]-E[0],C[1]-E[1],C[2]-E[2])\n",
    "# Moment about point E\n",
    "# Calculating the cross product\n",
    "M_E=((r_EC[1]*F[2]-r_EC[2]*F[1]),(r_EC[2]*F[0]-r_EC[0]*F[2]),(r_EC[0]*F[1]-r_EC[1]*F[0])) # N.m # The value taken for F is incorrect in textbook.\n",
    "# Unit vector\n",
    "n_AE=[(E[i]-A[i])/math.sqrt((E[0]-A[0])**2+(E[1]-A[1])**2+(E[2]-A[2])**2) for i in range(0,3)]\n",
    "# Moment of force about axis AE\n",
    "# finding the dot product\n",
    "M_AE=M_E[0]*n_AE[0]+M_E[1]*n_AE[1]+M_E[2]*n_AE[2] # N.m\n",
    "# Results\n",
    "print('The moment of the force about point E is %fi - %fj + %fk N.m'%M_E)\n",
    "print('The moment of force about axis AE is -%f N.m'%M_AE)\n",
    "# The value of M_AE & M_E is incorrect in the textbook.Incorrect value of force vector is taken in calculation of M_E\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.16 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The point of application should be shifted to: x=3.800000 m and z=4.100000 m\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "F=20 # kN # Force acting at O\n",
    "M_x=76 # kNm\n",
    "M_y=82 # kNm\n",
    "# Calculations\n",
    "x=M_x/F # m\n",
    "z=M_y/F # m\n",
    "# Results\n",
    "print('The point of application should be shifted to: x=%f m and z=%f m'%(x,z))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.17 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tension in cable AD is 2282.996811 N\n",
      "Tension in cable AB is 2040.860785 N\n",
      "Tension in cable AC is 1588.382888 N\n"
     ]
    }
   ],
   "source": [
    "import numpy\n",
    "# Initilization of variables\n",
    "W=5000 # N\n",
    "# Co-ordinates of various points\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",
    "# Calculations\n",
    "# Ref textbook for the values of tenion in the cable AB, AC & AD. The values consist of variables which cannot be defined here\n",
    "# We re-arrange and define the equations of equilibrium as matrices and solve them as,\n",
    "P=numpy.matrix('0.528,0.0,-0.472;0.0,0.47,-0.327;0.85,0.88,0.818')\n",
    "Q=numpy.matrix('0;0;5000')\n",
    "X=numpy.linalg.inv(P)*Q\n",
    "# Results\n",
    "print('Tension in cable AD is %f N'%X[2])\n",
    "print('Tension in cable AB is %f N'%X[0])\n",
    "print('Tension in cable AC is %f N'%X[1])\n",
    "#Ans for T_AB is incorrect in textbook.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.18 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reactions are: R_A=6.416667 kN ,R_C=3.892857 kN and R_B=-2.309524 kN\n"
     ]
    }
   ],
   "source": [
    "# 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 # kN\n",
    "# M_z=0\n",
    "R_C=((Q*x1)+(P*x2))/x1 # kN\n",
    "# sum F_y=0\n",
    "R_B=P+Q-R_A-R_C # kN\n",
    "# Results\n",
    "print('The reactions are: R_A=%f kN ,R_C=%f kN and R_B=%f kN'%(R_A,R_C,R_B))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 26.19 Appendix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The components of reaction at A are: A_x=-1.562500 kN , A_y=-1.687500 kN and A_z=6.250000 kN\n",
      "The tensions in the cable are: T_FE=5.387931 kN and T_GD=3.810976 kN\n"
     ]
    }
   ],
   "source": [
    "# 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=numpy.matrix('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=numpy.matrix('0;3;0;6.25;0')\n",
    "X=numpy.linalg.inv(P)*Q\n",
    "\n",
    "# Results\n",
    "print('The components of reaction at A are: A_x=%f kN , A_y=%f kN and A_z=%f kN'%(X[0],X[1],X[2]))\n",
    "print('The tensions in the cable are: T_FE=%f kN and T_GD=%f kN'%(X[3],X[4]))\n",
    "# The solution in the textbook is incorrect and yeilds singularity in matrix calculation."
   ]
  }
 ],
 "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
}