# Example 26.1 Appendix¶

In [7]:
import math
#Initilization of variables
P=[-5,2,14] #Point co-ordinates
#Calculations
r=math.sqrt(P[0]**2+P[1]**2+P[2]**2) #Magnitude of the poistion vector
#Direction cosines
l=P[0]/r
m=P[1]/r
n=P[2]/r
#Unit Vector calculations
r_unit=[]
r_unit[:]=[P[i]/r for i in range(0,3)]
#Results
print("The Position vector is %fi+%fj+%fk"%(P[0],P[1],P[2]))
print('The value of r is %f*l i + %f*m j + %f*n k'%(r,r,r))
print("The unit vector in the direction of r is %fi+%fj+%fk"%(r_unit[0],r_unit[1],r_unit[2]))

The Position vector is -5.000000i+2.000000j+14.000000k
The value of r is 15.000000*l i + 15.000000*m j + 15.000000*n k
The unit vector in the direction of r is -0.333333i+0.133333j+0.933333k


# Example 26.2 Appendix¶

In [6]:
import math
#Initilizatin of variable
F=10 #N
P_1=[2,4,3]
P_2=[1,-5,2]

#Calculations
d_x=P_2[0]-P_1[0]
d_y=P_2[1]-P_1[1]
d_z=P_2[2]-P_1[2]
d=math.sqrt(d_x**2+d_y**2+d_z**2)
Fx=(F/d)*d_x #N
Fy=(F/d)*d_y #N
Fz=(F/d)*d_z #N
#Direction cosines
l=Fx/F
m=Fy/F
n=Fz/F
#Angles
theta_x=math.degrees(math.acos(l)) #degrees
theta_y=math.degrees(math.acos(m)) #degrees
theta_z=math.degrees(math.acos(n)) #degrees

#Result
print("The force in vector notation is %fi%fj%fk"%(Fx,Fy,Fz))
print("Thetax=%f degrees,Thetay=%f degrees,Thetaz=%f degrees"%(theta_x,theta_y,theta_z))

The force in vector notation is -1.097643i-9.878783j-1.097643k
Thetax=96.301726 degrees,Thetay=171.069858 degrees,Thetaz=96.301726 degrees


# Example 26.3 Appendix¶

In [12]:
import math
#initiliation of variables
T=2500 #N
#Co-ordinates
Q=[40,0,-30]
P=[0,80,0]

#Calculations
mag_QP=math.sqrt((P[0]-Q[0])**2+(P[1]-Q[1])**2+(P[2]-Q[2])**2) #Magnitude
QP=[(P[0]-Q[0]),(P[1]-Q[1]),(P[2]-Q[2])]
F=[]
F[:]=[(T/mag_QP)*QP[i] for i in range(0,3)] #N
thetax=(math.acos(F[0]/T)*180/math.pi) #degrees
thetay=(math.acos(F[1]/T)*180/math.pi) #degrees
thetaz=(math.acos(F[2]/T)*180/math.pi) #degrees

#Result
print("The force vector is %fi+%fj+%fk N"%(F[0],F[1],F[2]))
#Answer in the textbook is printed as 1600 which is incorrect
print("The angles are thetax=%f,thetay=%f and thetaz=%f degrees"%(thetax,thetay,thetaz))

The force vector is -1059.997880i+2119.995760j+794.998410k N
The angles are thetax=115.087329,thetay=32.005383 and thetaz=71.458022 degrees


# Example 26.4 Appendix¶

In [14]:
import math
#initilization of variables
A=[2,-1,1]
B=[1,1,2]
C=[3,-2,4]
#Calculations
R=[A[0]+B[0]+C[0],A[1]+B[1]+C[1],A[2]+B[2]+C[2]] #Resultant
mag=math.sqrt(R[0]**2+R[1]**2+R[2]**2)
#Unit vector
U=[]
U[:]=[R[i]/mag for i in range(0,3)]
#Result
print("The unit vector is %fi%fj+%fk"%(U[0],U[1],U[2]))
#Answer for (k) is incorrect in the textbook

The unit vector is 0.635999i-0.212000j+0.741999k


# Example 26.5 Appendix¶

In [15]:
import math
#initilization of variables
A=[2,-6,-3]
B=[4,3,-1]
#Calculations
magA=math.sqrt(A[0]**2+A[1]**2+A[2]**2)
magB=math.sqrt(B[0]**2+B[1]**2+B[2]**2)

#Result
print("The product of both the vectors is %f"%AdotB)
print("The angle between them is %f degrees"%theta)

The product of both the vectors is -7.000000
The angle between them is 101.309932 degrees


# Example 26.6 Appendix¶

In [16]:
import math
#initilization of variables
A=[4,-3,1]
P=[2,3,-1]
Q=[-2,-4,3]
#Calculations
B=[Q[0]-P[0],Q[1]-P[1],Q[2]-P[2]]
magB=math.sqrt(B[0]**2+B[1]**2+B[2]**2)
#Result
print("The value of A.costheta is %f"%Acostheta)

The value of A.costheta is 1.000000


# Example 26.7 Appendix¶

In [1]:
import numpy as np
#Initilization of variables
F=np.array([5,10,-15])
a=np.array([1,0,3])
b=np.array([3,-1,-6])
#Calculations
d=b-a
work=F*d
Work=work[0]+work[1]+work[2]
#Result
print("The work done is %d units"%Work)

The work done is 135 units


# Example 26.8 Appendix¶

In [35]:
import math
#initilization of variables
A=[2,-6,-3]
B=[4,3,-1]
#Calculations
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]]
mag=math.sqrt(AcrossB[0]**2+AcrossB[1]**2+AcrossB[2]**2)
n=[AcrossB[i]/mag for i in range(0,3)]
magA=math.sqrt(A[0]**2+A[1]**2+A[2]**2)
magB=math.sqrt(B[0]**2+B[1]**2+B[2]**2)
theta=math.degrees(math.asin(mag/(magA*magB)))
#Result
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
print("The angle between the two is %f degrees"%theta)
# Only 1 value for theta has been solved

The cross prcoduct of the two vectors is 15.000000i -10.000000j+30.000000k
The angle between the two is 78.690068 degrees


# Example 26.9 Appendix¶

In [3]:
import math
# Initilization of Variable
# Points As martices
A=[0,1,2]
B=[1,3,-2]
P=[3,6,4]
a_s=2 # Angular speed in rad/s

# Calculations
C=(B[0]-A[0],B[1]-A[1],B[2]-A[2])
magC=(C[0]**2+C[1]**2+C[2]**2)**0.5 # Magnitude of the Vector C
# Unit vector
C_unit=(C[0]/magC,C[1]/magC,C[2]/magC) # Unit vector
# Position Vector
r=(P[0]-A[0],P[1]-A[1],P[2]-A[2])
# Velocity Vector
# Calculating the cross product as,
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])
# Vector notation
V_n=[]
V_n[:]=[(a_s/magC)*V[i] for i in range(0,3)]
# Velocity Magnitude
magV=math.sqrt(V[0]**2+V[1]**2+V[2]**2)
v=(a_s/magC)*magV
# Result
print("The vector notation of velocity is %fi %fj %fk"%(V_n[0],V_n[1],V_n[2]))
print("The magnitude of the Velocity Vector is %f"%v)

The vector notation of velocity is 10.474459i -6.110101j -0.436436k
The magnitude of the Velocity Vector is 12.134171


# Example 26.10 Appendix¶

In [4]:
import math
# Initilization of variables
# Points as matrices
O=[-2,3,5]
P=[1,-2,4]
Q=[5,2,3]
F=[4,4,-1] # Force vector
# Calculations
# Positon vector , r_2 gives the same answer as r_1
r_1=(P[0]-O[0],P[1]-O[1],P[2]-O[2])
# Moment
# Calculating the cross product
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])
# Results
print('The Moment about point O is %fi %fj+%fk'%(M[0],M[1],M[2]))

The Moment about point O is 9.000000i -1.000000j+32.000000k


# Example 26.11 Appendix¶

In [40]:
import math
# Initilization of variables
# Points as matrices
P=[1,-1,2] # Point where force is applied
O=[2,-1,3] # point where moment is to be found
F=[3,2,-4] # Force vector
# Calculations
# Position vector of point P wrt O
r=(P[0]-O[0],P[1]-O[1],P[2]-O[2])
# Moment
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])
# Resuts
print('The moment of the force is %fi %fj %fk'%(M[0],M[1],M[2]))

The moment of the force is 2.000000i -7.000000j -2.000000k


# Example 26.12 Appendix¶

In [45]:
import math
# Initilization of variables
f=22 # N
# Points as matrices
A=[4,-1,7]
O=[1,-3,2]
V=[9,6,-2] # Given vector
# Calculations
# Unit vector in the direction of the vector
denom=math.sqrt(V[0]**2+V[1]**2+V[2]**2)
v=[V[i]/denom for i in range(0,3)]
# Force
F=[f*v[i] for i in range(0,3)]
# Position vector of point A wrt O
r=(A[0]-O[0],A[1]-O[1],A[2]-O[2])
# Moment
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])
# Results
print('The moment is %fi + %fj + %f k'%(M[0],M[1],M[2]))

The moment is -68.000000i + 102.000000j + 0.000000 k


# Example 26.13 Appendix¶

In [48]:
import math
# Initilization of variables
# Force Vector
F=[50,-80,30]
# from fig.13
theta1=30 # angles by which the axis is rotated [ all in degrees]
theta2=60
theta3=90
theta4=120
theta5=0
# Calculations
# Unit vector in u-direction
u_unit=(1*math.cos(theta1*math.pi/180),1*math.cos(theta2*math.pi/180),1*math.cos(theta3*math.pi/180))
# Unit vector in v-direction
v_unit=(1*math.cos(theta4*math.pi/180),1*math.cos(theta1*math.pi/180),1*math.cos(theta3*math.pi/180))
# Unit vector in w-direction
w_unit=(1*math.cos(theta3*math.pi/180),1*math.cos(theta3*math.pi/180),1*math.cos(theta5*math.pi/180))
# Components of force
# finding the dot product as
u=F[0]*u_unit[0]+F[1]*u_unit[1]+F[2]*u_unit[2] # N
v=F[0]*v_unit[0]+F[1]*v_unit[1]+F[2]*v_unit[2] # N
w=F[0]*w_unit[0]+F[1]*w_unit[1]+F[2]*w_unit[2] # N
# Results
print('The components of the force is along u=%f N,along v=%f N,along w=%f N'%(u,v,w))

The components of the force is along u=3.301270 N,along v=-94.282032 N,along w=30.000000 N


# Example 26.14 Appendix¶

In [64]:
import math
# Initilization of variables
f=100 # N # magnitude of force
# Co-ordinates of corners of the box as matrices
A=[0,0,0]
B=[0.5,0,0]
C=[0.5,0,1]
D=[0,0,1]
E=[0,0.5,0]
F=[0.5,0.5,0]
G=[0.5,0.5,1]
H=[0,0.5,1]
# Calculations
# Force vector
Fmag=f/math.sqrt((F[0]-C[0])**2+(F[1]-C[1])**2+(F[2]-C[2])**2)
F=[Fmag*(F[i]-C[i]) for i in range(0,3)]
# Position vector
r_EC=(C[0]-E[0],C[1]-E[1],C[2]-E[2])
# Calculating the cross product
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.
# Unit vector
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)]
# Moment of force about axis AE
# finding the dot product
M_AE=M_E[0]*n_AE[0]+M_E[1]*n_AE[1]+M_E[2]*n_AE[2] # N.m
# Results
print('The moment of the force about point E is %fi - %fj + %fk N.m'%M_E)
print('The moment of force about axis AE is -%f N.m'%M_AE)
# The value of M_AE & M_E is incorrect in the textbook.Incorrect value of force vector is taken in calculation of M_E

The moment of the force about point E is 0.000000i - 44.721360j + 22.360680k N.m
The moment of force about axis AE is -44.721360 N.m


# Example 26.16 Appendix¶

In [15]:
from __future__ import division
# Initilization of variables
F=20 # kN # Force acting at O
M_x=76 # kNm
M_y=82 # kNm
# Calculations
x=M_x/F # m
z=M_y/F # m
# Results
print('The point of application should be shifted to: x=%f m and z=%f m'%(x,z))

The point of application should be shifted to: x=3.800000 m and z=4.100000 m


# Example 26.17 Appendix¶

In [5]:
import numpy
# Initilization of variables
W=5000 # N
# Co-ordinates of various points
A=[0,4.5,0]
B=[2.8,0,0]
C=[0,0,-2.4]
D=[-2.6,0,1.8]
# Calculations
# Ref textbook for the values of tenion in the cable AB, AC & AD. The values consist of variables which cannot be defined here
# We re-arrange and define the equations of equilibrium as matrices and solve them as,
P=numpy.matrix('0.528,0.0,-0.472;0.0,0.47,-0.327;0.85,0.88,0.818')
Q=numpy.matrix('0;0;5000')
X=numpy.linalg.inv(P)*Q
# Results
print('Tension in cable AD is %f N'%X[2])
print('Tension in cable AB is %f N'%X[0])
print('Tension in cable AC is %f N'%X[1])
#Ans for T_AB is incorrect in textbook.

Tension in cable AD is 2282.996811 N
Tension in cable AB is 2040.860785 N
Tension in cable AC is 1588.382888 N


# Example 26.18 Appendix¶

In [20]:
from __future__ import division
# Initilization of variables
P=5 # kN
Q=3 # kN
C=5 # kNm # couple
#  ref fig.20 # Notations have been assumed
z1=1.5 # m
z2=0.625 # m
z3=0.5 # m
x1=3.5 # m
x2=0.625 # m
# Calculations
# sum M_x=0
R_A=((P*z2)+(Q*z3)+C)/z1 # kN
# M_z=0
R_C=((Q*x1)+(P*x2))/x1 # kN
# sum F_y=0
R_B=P+Q-R_A-R_C # kN
# Results
print('The reactions are: R_A=%f kN ,R_C=%f kN and R_B=%f kN'%(R_A,R_C,R_B))

The reactions are: R_A=6.416667 kN ,R_C=3.892857 kN and R_B=-2.309524 kN


# Example 26.19 Appendix¶

In [7]:
import numpy
# Initilization of variables
F=2 # kN
W=1 # kN
# Co-ordinates as matrices
A=[0,0,0]
C=[0,0,1.2]
B=[0,0,2.5]
D=[-1,1,0]
E=[1,1,0]
F=[0,0,1]
G=[0,0,2]
# Force vector
f=[0,-2,0]
# Weight vector
w=[0,-1,0]
# Calculations
# we have 5 unknowns: A_x,A_y,A_z,T_FE & T_GD
# we define and solve eqn's 1,2,3,4&5 using matrix as,
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')
Q=numpy.matrix('0;3;0;6.25;0')
X=numpy.linalg.inv(P)*Q

# Results
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]))
print('The tensions in the cable are: T_FE=%f kN and T_GD=%f kN'%(X[3],X[4]))
# The solution in the textbook is incorrect and yeilds singularity in matrix calculation.

The components of reaction at A are: A_x=-1.562500 kN , A_y=-1.687500 kN and A_z=6.250000 kN
The tensions in the cable are: T_FE=5.387931 kN and T_GD=3.810976 kN