# Example 26.1 Appendix¶

In :
import math
#Initilization of variables
P=[-5,2,14] #Point co-ordinates
#Calculations
r=math.sqrt(P**2+P**2+P**2) #Magnitude of the poistion vector
#Direction cosines
l=P/r
m=P/r
n=P/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,P,P))
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,r_unit,r_unit))

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 :
import math
#Initilizatin of variable
F=10 #N
P_1=[2,4,3]
P_2=[1,-5,2]

#Calculations
d_x=P_2-P_1
d_y=P_2-P_1
d_z=P_2-P_1
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 :
import math
#initiliation of variables
T=2500 #N
#Co-ordinates
Q=[40,0,-30]
P=[0,80,0]

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

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

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


# Example 26.5 Appendix¶

In :
import math
#initilization of variables
A=[2,-6,-3]
B=[4,3,-1]
#Calculations
magA=math.sqrt(A**2+A**2+A**2)
magB=math.sqrt(B**2+B**2+B**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 :
import math
#initilization of variables
A=[4,-3,1]
P=[2,3,-1]
Q=[-2,-4,3]
#Calculations
B=[Q-P,Q-P,Q-P]
magB=math.sqrt(B**2+B**2+B**2)
#Result
print("The value of A.costheta is %f"%Acostheta)

The value of A.costheta is 1.000000


# Example 26.7 Appendix¶

In :
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+work+work
#Result
print("The work done is %d units"%Work)

The work done is 135 units


# Example 26.8 Appendix¶

In :
import math
#initilization of variables
A=[2,-6,-3]
B=[4,3,-1]
#Calculations
AcrossB=[A*B-B*A,A*B-A*B,A*B-A*B]
mag=math.sqrt(AcrossB**2+AcrossB**2+AcrossB**2)
n=[AcrossB[i]/mag for i in range(0,3)]
magA=math.sqrt(A**2+A**2+A**2)
magB=math.sqrt(B**2+B**2+B**2)
theta=math.degrees(math.asin(mag/(magA*magB)))
#Result
print("The cross prcoduct of the two vectors is %fi %fj+%fk"%(AcrossB,AcrossB,AcrossB)) #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 :
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-A,B-A,B-A)
magC=(C**2+C**2+C**2)**0.5 # Magnitude of the Vector C
# Unit vector
C_unit=(C/magC,C/magC,C/magC) # Unit vector
# Position Vector
r=(P-A,P-A,P-A)
# Velocity Vector
# Calculating the cross product as,
V=(C*r-C*r,C*r-C*r,C*r-C*r)
# Vector notation
V_n=[]
V_n[:]=[(a_s/magC)*V[i] for i in range(0,3)]
# Velocity Magnitude
magV=math.sqrt(V**2+V**2+V**2)
v=(a_s/magC)*magV
# Result
print("The vector notation of velocity is %fi %fj %fk"%(V_n,V_n,V_n))
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 :
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-O,P-O,P-O)
# Moment
# Calculating the cross product
M=(r_1*F-r_1*F,r_1*F-r_1*F,r_1*F-r_1*F)
# Results
print('The Moment about point O is %fi %fj+%fk'%(M,M,M))

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


# Example 26.11 Appendix¶

In :
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-O,P-O,P-O)
# Moment
M=(r*F-r*F,r*F-r*F,r*F-r*F)
# Resuts
print('The moment of the force is %fi %fj %fk'%(M,M,M))

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


# Example 26.12 Appendix¶

In :
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**2+V**2+V**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-O,A-O,A-O)
# Moment
M=(r*F-r*F,r*F-r*F,r*F-r*F)
# Results
print('The moment is %fi + %fj + %f k'%(M,M,M))

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


# Example 26.13 Appendix¶

In :
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*u_unit+F*u_unit+F*u_unit # N
v=F*v_unit+F*v_unit+F*v_unit # N
w=F*w_unit+F*w_unit+F*w_unit # 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 :
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-C)**2+(F-C)**2+(F-C)**2)
F=[Fmag*(F[i]-C[i]) for i in range(0,3)]
# Position vector
r_EC=(C-E,C-E,C-E)
# Calculating the cross product
M_E=((r_EC*F-r_EC*F),(r_EC*F-r_EC*F),(r_EC*F-r_EC*F)) # N.m # The value taken for F is incorrect in textbook.
# Unit vector
n_AE=[(E[i]-A[i])/math.sqrt((E-A)**2+(E-A)**2+(E-A)**2) for i in range(0,3)]
# Moment of force about axis AE
# finding the dot product
M_AE=M_E*n_AE+M_E*n_AE+M_E*n_AE # 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 :
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 :
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)
print('Tension in cable AB is %f N'%X)
print('Tension in cable AC is %f N'%X)
#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 :
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 :
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,X,X))
print('The tensions in the cable are: T_FE=%f kN and T_GD=%f kN'%(X,X))
# 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