Chapter 10: First Moments and Centroids

Example 10.10-5, Page no 160

In [4]:
import math
import numpy as np

#Initilization of variables
r=50 #mm
L1=75 #mm
L2=pi*r #mm
L3=61.2 #mm
# as theta1=45 degrees & theta2=60 degrees
sintheta1=sqrt(2)**-1
costheta1=sqrt(2)**-1
sintheta2=sqrt(3)*2**-1
costheta2=2**-1

#Calculations
x_bar=np.array([(L1/2)*costheta1,L1*costheta1+r,L1*costheta1+100+(L3/2)*costheta2]) #mm
y_bar=np.array([(L1/2)*sintheta1,L1*sintheta1+(2*r)/pi,(L3/2)*sintheta2]) #mm
#Centroid Calculations
x=(L1*x_bar[0]+L2*x_bar[1]+L3*x_bar[2])/(L1+L2+L3) #mm
y=(L1*y_bar[0]+L2*y_bar[1]+L3*y_bar[2])/(L1+L2+L3) #mm

#Result
print'The centroid is as follows:'
print'x=',round(x,1),"mm"
print'y=',round(y,1),"mm"

# The answer may wary due to decimal point descrepancy
The centroid is as follows:
x= 97.0 mm
y= 57.7 mm

Example 10.10-6, Page no 160

In [13]:
import math

#Initilization of variables
theta=75 #degrees
theta1=30 #degrees
sintheta=0.96
costheta=0.25
sintheta1=2**-1
costheta1=sqrt(3)*2**-1
alpha=(150*pi)/180 #rad
r=1
lhor=14 #in

#calculations
a=((2*r)/alpha)*sintheta #in
p=90-theta
sinp=0.259
y=-a*sinp #in
#Length of arc
l=r*alpha #in
#Slope length calculations
DF=7 #in
AB=DF #in
BC=1 #in
BF=BC*costheta1 #in
FC=BC*sintheta1 #in
DC=DF+FC #in
EC=DC/costheta1 #in
#Centroid of EC is at G
yslope=0.5*EC*sintheta1+BF #in
#Y of composite figure
Y=((2*l*y)+14*-1+(2*EC*yslope))/(2*l+lhor+2*EC) #in

#Result
print'The centroid is at Y=',round(Y,2),"in"
The centroid is at Y= 1.03 in

Example 10.10-11, Page no 163

In [14]:
import math

#Initilization of variables
a=100 #mm
b=150 #mm
A1=2*10**4 #mm**2
A2=5*10**3 #mm**2
A3=(pi*(a/2)**2)/2 #mm**2

#Calculations
x=(A1*a+A2*(133.3)-A3*b)/(A1+A2-A3) #mm
y=(A1*a*0.5+A2*(116.66)-A3*((4*a*0.5)/(3*pi)))/(A1+A2-A3) #mm

#Result
print'The centroidal distances are'
print'x=',round(x,1),"mm"
print'y=',round(y,1),"mm"
The centroidal distances are
x= 98.6 mm
y= 71.2 mm

Example 10.10-16, Page no 166

In [17]:
import math

#Initilization of variables
V=np.array([1728*10**3,432*10**3,7.54*10**3])
x_bar=np.array([60,140,60]) #mm
y_bar=np.array([30,20,30]) #mm

#Calculations
x=(V[0]*x_bar[0]+V[1]*x_bar[1]+V[2]*x_bar[2])/(V[0]+V[1]+V[2]) #mm
y=(V[0]*y_bar[0]+V[1]*y_bar[1]+V[2]*y_bar[2])/(V[0]+V[1]+V[2]) #mm
z=120 #mm from symmetry

#Result
print'The centroid is at'
print'x=',round(x,1),"mm"
print'y=',round(y,1),"mm"
print'z=',round(z,1),"mm"

#Decimal accuracy causes discrepancy in answers
The centroid is at
x= 75.9 mm
y= 28.0 mm
z= 120.0 mm

Example 10.10-17, Page no 166

In [22]:
import math

#Initilization of variables
# Here tx=30 degrees,ty=45 degrees& tz=60 degrees,, thus
sintx=2**-1
costx=sqrt(3)*2**-1
sinty=sqrt(2)**-1
costy=sqrt(2)**-1
sintz=sqrt(3)*2**-1
costz=2**-1

#Calculations
V=np.array([10,15,25]) #in**3
x_bar=np.array([4,12,24]) #in
y_bar=np.array([4*costx,-6*costy,-4*costz])
z_bar=np.array([-4*sintx,6*sinty,-4*sintz])
#Centroid calculations
x=(V[0]*x_bar[0]+V[1]*x_bar[1]+V[2]*x_bar[2])/(V[0]+V[1]+V[2]) #in
y=(V[0]*y_bar[0]+V[1]*y_bar[1]+V[2]*y_bar[2])/(V[0]+V[1]+V[2]) #in
z=(V[0]*z_bar[0]+V[1]*z_bar[1]+V[2]*z_bar[2])/(V[0]+V[1]+V[2]) #in

#Result
print'The centroid of three volumes is at'
print'x=',round(x,1),"in"
print'y=',round(y,2),"in"
print'z=',round(z,2),"in"

# The ans for x is off by 0.4 in
The centroid of three volumes is at
x= 16.0 in
y= -1.58 in
z= -0.86 in

Example 10.10-26, Page no 171

In [2]:
# Part a
# Pefer textbook for part a.

# Part b

# Initilization of variables
w=150 #lb/ft**2
h=2 #ft height of the load
s=8 #ft span
b=2 #ft

import math
from scipy.integrate import quad
def integrand(x, a, b):
    return x*(150*(x/4)*2)
a=1
b=1
M=quad(integrand, 0, s, args=(a,b))
Rr=M[0]/(2*s) #lb

# Results
print'The value of M is',round(M[0]),"lb-ft"
print'The value of Rr is',round(Rr),"lb"
The value of M is 12800.0 lb-ft
The value of Rr is 800.0 lb

Example 10.10-27, Page no 172

In [5]:
# Initilization of variables

rho_m=1000 # kg/m**3
h=0.3 # m height of hole
b=0.6 # m width of hole

import math
from scipy.integrate import quad
def integrand(y, a, b):
    return y*9.8*rho_m*(1.2-y)*(0.6)
a=1
b=1
I=quad(integrand, 0, h, args=(a,b))
B=I[0]/(2*(0.3))

# Results
print'The value of B is',round(B),"N"
The value of B is 441.0 N

Example 10.10-28, Page no 172

In [24]:
import math

#Initilization of variables
l=62.4 #lb/ft**3
h=12 #ft
f=105 #lb/ft**3

#Calculations
p1=l*h #lb/ft**2
#Total force on left side
#Simplfying the equation we get a three degree equation in d
#solving for d
p=np.array([3**-1,0,-144,467])
r=roots(p)
d=r[2] #ft

#Result
print'The value of d is',round(d,2),"feet"
The value of d is 3.33 feet