##Part B Chapter 3 Example 1 pg no 496
##find the Distance of G from AB
import math
AB=160.;##mm
AC=200.;##mm
BF=25.;##mm
CD=25.;##mm
A=AB*BF+CD*(AC-BF);##mm^2
##Distance of G from AB
ybar=(AB*BF*CD/2.+CD*(AC-BF)*((AC-BF)/2.+CD))/A;##mm
print"%s %.2f %s"%("Distance of G from AB(mm)",ybar,"");
##Distance of G from CD
CG=AC-ybar;##mm
print"%s %.2f %s"%("Distance of G from CD(mm) : ",CG,"");
##Part B Chapter 3 Example 2 pg no 496
##find the From reference axes AF, centroid
import math
BC=25.;##mm
AB=125.;##mm
AF=85.;##mm
EF=25.;##mm
A_GBCD=BC*(AB-EF);##mm^2
A_GEFA=AF*EF;##mm^2
##Distance of CG from AF
ybar=((A_GBCD*(AB-2.*EF)+A_GEFA*EF/2.)/(A_GBCD+A_GEFA));##mm
##Distance of CG from AB
xbar=((A_GBCD*(BC/2.)+A_GEFA*AF/2.)/(A_GBCD+A_GEFA));##mm
print"%s %.2f %s"%("From reference axes AF, centroid is(mm) : ",ybar,"");
print"%s %.2f %s"%("From reference axes AB, centroid is(mm) : ",xbar,"");
##Part B Chapter 3 Example 3 pg no 497
##find the From reference axes AF, centroid
##find the From reference axes AF, centroid
import math
AB=200.;##mm
BC=300.;##mm
CD=260.;##mm
a1=1/2.*AB*CD;##mm^2(Area of ABE)
a2=math.pi*(BC/2.)**2./2.;##mm^2(Area of semicircle)
a3=BC*CD;##mm^2(Area of BECD)
x1bar=1/3.*CD;##mm
y1bar=BC+1/3.*AB;##mm
x2bar=4/3.*(BC/2.)/math.pi;##mm
y2bar=BC/2.;##mm
x3bar=1/2.*CD;##mm
y3bar=BC/2.;##mm
##Distance of CG from AC
xbar=(a1*x1bar-a2*x2bar+a3*x3bar)/(a1-a2+a3);##mm
##Distance of CG from CD
ybar=(a1*y1bar-a2*y2bar+a3*y3bar)/(a1-a2+a3);##mm
print"%s %.2f %s"%("From reference axes CD, centroid ybar is(mm) : ",ybar,"");
print"%s %.2f %s"%("from reference axes AC, centroid xbar is(mm) : ",xbar,"");
##Part B Chapter 3 Example 4 pg no 499
##find the From reference axes AF, centroid
AB=160.;##mm
BC=40.;##mm
EF=100.;##mm
FH=40.;##mm
CH=120.;##mm
a1=EF*FH;##mm^2
a2=20.*CH;##mm^2
a3=AB*BC;##mm^2
y1bar=20.+CH+FH;##mm
y2bar=CH/2.+BC;##mm
y3bar=BC/2.;##mm
##Distance of CG from AB
ybar=(a1*y1bar+a2*y2bar+a3*y3bar)/(a1+a2+a3);##mm
print"%s %.2f %s"%("From reference axes AB, centroid ybar is(mm) : ",ybar,"");
##Part B Chapter 3 Example 5 pg no 500
##find the From reference axes AB, centroid ybar
import math
EF=150.;##mm
GH=150.;##mm
CD=150.;##mm
AB=250.;##mm
AE=10.;##mm
DH=10.;##mm
CH=120.;##mm
CD_t=10.;##mm(thickness of CD section)
a1=AB*AE;##mm^2
a2=180.*AE;##mm^2
a4=180.*AE;##mm^2
a3=450.*10.;##mm^2
a5=CD*AE;##mm^2
y1bar=5.;y2bar=15.;y3bar=225.+20.;y4bar=475.;y5bar=485.;##mm
##Distance of CG from AB
ybar=(a1*y1bar+a2*y2bar+a3*y3bar+a4*y4bar+a5*y5bar)/(a1+a2+a3+a4+a5);##mm
print"%s %.2f %s"%("From reference axes AB, centroid ybar is(mm) : ",ybar,"");