Support our Blind Hand Charity by donating at 9818291723. Your contribution has the potential to bring about significant positive change for humanity.

Search This Blog

Saturday, July 8, 2023

QUADILATERAL PLOTTER

import matplotlib.pyplot as mp
print("Enter the coordinates of A ")
x1=int(input("Enter the x1-coordinate = "))
y1=int(input("Enter the y1-coordinate = "))
print("Enter the coordinates of B ")
x2=int(input("Enter the x2-coordinate = "))
y2=int(input("Enter the y2-coordinate = "))
print("Enter the coordinates of C ")
x3=int(input("Enter the x3-coordinate = "))
y3=int(input("Enter the y3-coordinate = "))
print("Enter the coordinates of D ")
x4=int(input("Enter the x4-coordinate = "))
y4=int(input("Enter the y4-coordinate = "))
m1=(x1+x3)/2
m2=(y1+y3)/2
m3=(x2+x4)/2
m4=(y2+y4)/2
s1=(((x2-x1)**2)+((y2-y1)**2))**0.5
s2=(((x3-x2)**2)+((y3-y2)**2))**0.5
s3=(((x4-x3)**2)+((y4-y3)**2))**0.5
s4=(((x1-x4)**2)+((y1-y4)**2))**0.5
if s1==s3==s2==s4:
    if m1==m3 and m2==m4:
        mp.title('It is a Square')
        x=[x1,x2]
        y=[y1,y2]
        mp.plot(x,y,'p-b',ms=5,mec='black')
        x=[x2,x3]
        y=[y2,y3]
        mp.plot(x,y,'p-r',ms=8,mec='black')
        x=[x3,x4]
        y=[y3,y4]
        mp.plot(x,y,'p-y',ms=8,mec='black')
        x=[x4,x1]
        y=[y4,y1]
        mp.plot(x,y,'p-g',ms=8,mec='black')
    elif m1!=m3 and m2!=m4:
        mp.title('It is a Rohumbus')
        x=[x1,x2]
        y=[y1,y2]
        mp.plot(x,y,'p-b',ms=5,mec='black')
        x=[x2,x3]
        y=[y2,y3]
        mp.plot(x,y,'p-r',ms=8,mec='black')
        x=[x3,x4]
        y=[y3,y4]
        mp.plot(x,y,'p-y',ms=8,mec='black')
        x=[x4,x1]
        y=[y4,y1]
        mp.plot(x,y,'p-g',ms=8,mec='black')
elif s1==s3 and s2==s4:
    if m1==m3 and m2==m4:
        mp.title('It is a Parallelogram')
        x=[x1,x2]
        y=[y1,y2]
        mp.plot(x,y,'p-b',ms=5,mec='black')
        x=[x2,x3]
        y=[y2,y3]
        mp.plot(x,y,'p-r',ms=8,mec='black')
        x=[x3,x4]
        y=[y3,y4]
        mp.plot(x,y,'p-y',ms=8,mec='black')
        x=[x4,x1]
        y=[y4,y1]
        mp.plot(x,y,'p-g',ms=8,mec='black')
    elif m1!=m3 and m2!=m4:
        mp.title('It is a Rectangle')
        x=[x1,x2]
        y=[y1,y1]
        mp.plot(x,y,'p-b',ms=5,mec='black')
        x=[x2,x3]
        y=[y2,y3]
        mp.plot(x,y,'p-r',ms=8,mec='black')
        x=[x3,x4]
        y=[y3,y3]
        mp.plot(x,y,'p-y',ms=8,mec='black')
        x=[x4,x1]
        y=[y4,y1]
        mp.plot(x,y,'p-g',ms=8,mec='black')
else:
    print("No specific quadrilateral formed")
mp.show()