#NAME: MUHAMMAD ZAID
#ROLL NO: CN-23032
# [LAB SESSION : 6]
#CALCULATE THE CENTROIDS OT THE FOLLOWING GIVEN SHAPES
# C-SHAPE
print("Enter dimensions for rectangle # 1: ")
x1 = int(input("Enter value of x1: "))
y1 = int(input("Enter value of y1: "))
A1 = y1 * x1
print("Enter dimensions for rectangle # 2: ")
x2 = int(input("Enter value of x2: "))
y2 = int(input("Enter value of y2: "))
A2 = y2 * x2
print("Enter dimensions for rectangle # 3: ")
x3 = int(input("Enter value of x3: "))
y3 = int(input("Enter value of y3: "))
A3 = y3 * x3
# CENTROIDS FOR Y
cen_y1 = y2 - y1/2
cen_y2 = y2/2
cen_y3 = y3/2
# CENTROIDS FOR X
cen_x1 = x1/2 + x2
cen_x2 = x2 / 2
cen_x3 = x3/2 + x2
x = ((A1*cen_x1)+(A3*cen_x2)+(A3*cen_x3))/(A1+A2+A3)
Y = ((A1*cen_y1)+(A3*cen_y2)+(A3*cen_y3))/(A1+A2+A3)
print("The centroidal axis is located at (x,y) :(" ,x , "," ,Y ,")")
# INVERTED C-SHAPE
print("Enter dimensions for rectangle #1: ")
x1=int(input("Enter values of x1: "))
y1=int(input("Enter value of y1: "))
A1= y1*x1
print("Enter dimensions for rectangle #2: ")
x2=int(input("Enter values of x2: "))
y2=int(input("Enter value of y2: "))
A2= y2*x2
print("Enter dimensions for rectangle #3: ")
x3=int(input("Enter values of x3: "))
y3=int(input("Enter value of y3: "))
A3= y3*x3
# CENTROIDS FOR Y
cen_y1 = y1/2
cen_y2 = y1 + y2/2
cen_y3 = y1 + y2 + y3/2
# CENTROIDS FOR X
cen_x1 = x1/2
cen_x2 = x1 - x2/2
cen_x3 = x3/2
x = ((A1*cen_x1)+(A2*cen_x2)+(A3*cen_x3))/(A1+A2+A3)
y = ((A1*cen_y1)+(A2*cen_y2)+(A3*cen_y3))/(A1+A2+A3)
print("The centroidal axis is located at (x,y) : (" , x, ",",y, ")")
# INVERTED T-SHAPE
print("Enter dimensions for rectangle #1: ")
x1=float(input("Enter values of x1: "))
y1=float(input("Enter value of y1: "))
A1= y1*x1
print("Enter dimensions for rectangle #2: ")
x2=float(input("Enter values of x2: "))
y2=float(input("Enter value of y2: "))
A2= y2*x2
# CENTROIDS FOR Y
cen_y1 = y2 - y1/2
cen_y2 = y2/2
# CENTROIDS FOR X
cen_x1 = x1/2
cen_x2 = x1/2
x = ((A1*cen_x1)+(A2*cen_x2))/(A1+A2)
y = ((A1*cen_y1)+(A2*cen_y2))/(A1+A2)
print("The centroidal axis is located at (x,y) : (" , x, ",",y, ")")
# T-SHAPE
print("Enter dimensions for rectangle #1: ")
x1=float(input("Enter values of x1: "))
y1=float(input("Enter value of y1: "))
A1= y1*x1
print("Enter dimensions for rectangle #2: ")
x2=float(input("Enter values of x2: "))
y2=float(input("Enter value of y2: "))
A2= y2*x2
# CENTROIDS FOR Y
cen_y1 = y2 + y1/2
cen_y2 = y2/2
# CENTROIDS FOR X
cen_x1 = x1/2
cen_x2 = x1/2
x = ((A1*cen_x1)+(A2*cen_x2))/(A1+A2)
y = ((A1*cen_y1)+(A2*cen_y2))/(A1+A2)
print("The centroidal axis is located at (x,y) : (" , x, ",",y, ")")