Aide programme

Fermé
deristix Messages postés 55 Date d'inscription   Statut Membre Dernière intervention   -  
georges97 Messages postés 13765 Date d'inscription   Statut Contributeur Dernière intervention   -

Bonsoir, 

je suis à la recherche de quelqu'un calé en python de préférence pour pouvoir m'aider sur un projet que je dois faire pour l'école, j'ai quand même bien avancé mais je suis bloqué a l'heure actuelle .

Donc j'aurais besoin de l'aide de quelqu'un qui pourrait m'aider sur ce projet.

#ce programme sert à reconnaitre des figures géométriques particulières dans un nuage de points


import pandas as pd
df = pd.read_csv("monFichier_test.csv")
print (df)


'''cette fonction permet de definir un carré'''
def test_carre(xA,yA,xB,yB,xC,yC,xD,yD):
    a=((xB-xA)**2+(yB-yA)**2)
    b=((xC-xB)**2+(yC-yB)**2)
    c=((xD-xC)**2+(yD-yC)**2)
    d=((xA-xD)**2+(yA-yD)**2)
    if a==b==c==d and ((xC-xB)*(xD-xC)+(yC-yB)*(yD-yC))==0 and ((xB-xA)*(xA-xD)+(yB-yA)*(yA-yD))==0:
        return True
    else:
        return False

'''cette fonction permet de definir un rectangle '''
def test_rectangle(xA,yA,xB,yB,xC,yC,xD,yD):
    a=((xB-xA)**2+(yB-yA)**2)
    b=((xC-xB)**2+(yC-yB)**2)
    c=((xD-xC)**2+(yD-yC)**2)
    d=((xA-xD)**2+(yA-yD)**2)
    if a==c and b==d and ((xC-xB)*(xD-xC)+(yC-yB)*(yD-yC))==0 and ((xB-xA)*(xA-xD)+(yB-yA)*(yA-yD))==0:
         return True
    else:
         return False


'''cette fonction permet de definir un triangle rectangle'''
def test_trianglerectangle(xA,yA,xB,yB,xC,yC):
    a=((xB-xA)**2+(yB-yA)**2)
    b=((xC-xB)**2+(yC-yB)**2)
    c=((xA-xC)**2+(yA-yC)**2)
    if b*b==a*a+c*c and ((xB-xA)*(xC-xA)+(yB-yA)*(yC-yA))==0:
        return True
    else:
         return False


from itertools import*
def search_figures(A,C):
    n=len(A)
    l=len(C)
    B=list(range(0,n,2))
    trianglerectangle=[]
    carre=[]
    rectangle=[]
    RESULTAT={}
    '''je fais la recherche de triangles rectangles'''
    C=list(combinations(B,3))
    for tri in C:
        xA = A[tri[0]]
    yA = A[tri[0]][1]
    xB = A[tri[1]]
    yB = A[tri[1]][1]
    xC = A[tri[2]]
    yC = A[tri[2]][1]
    print("av",xA,yA,xB,yB,xC,yC)
    if test_trianglerectangle(xA,yA,xB,yB,xC,yC):
            trianglerectangle.append((tri[0],tri[1],tri[2]))
    RESULTAT.update({"trianglerectangle":trianglerectangle})

    '''je fais la recherche de carré'''
    C=list(combinations(B,3))
    for tri in C:
        xA = A[tri[0]]
    yA = A[tri[0]][1]
    xB = A[tri[1]]
    yB = A[tri[1]][1]
    xC = A[tri[2]]
    yC = A[tri[2]][1]
    xD = A[tri[3]]
    yD = A[tri[3]][1]
    print("av",xA,yA,xB,yB,xC,yC,xD,yD)
    if test_carré(xA,yA,xB,yB,xC,yC,xD,yD):
            carré.append((tri[0],tri[1],tri[2],tri[3]))
    RESULTAT.update({"carre":carre})

    '''je fais la recherche de rectangle'''
    C=list(combinations(B,3))
    for tri in C:
       xA = A[tri[0]]
    yA = A[tri[0]][1]
    xB = A[tri[1]]
    yB = A[tri[1]][1]
    xC = A[tri[2]]
    yC = A[tri[2]][1]
    xD = A[tri[3]]
    yD = A[tri[3]][1]
    print("av",xA,yA,xB,yB,xC,yC,xD,yD)
    if test_rectangle(xA,yA,xB,yB,xC,yC):
            rectangle.append((tri[0],tri[1],tri[2],tri[3]))
    RESULTAT.update({"rectangle":rectangle})

    '''la  structure retournée est le dictionnaire RESULTAT'''
    return(RESULTAT)


import matplotlib.pyplot as plt
x = [47.17788031846174
,9.155162513788252
,87.31106451765086
,90.18098777410545
,85.73425568394163
,69.21660923542944
,87.42386051005897
,35.27685634185226
,83.01845522622216
,45.32537448340496
,51.322646552859695
,69.9527028251635
,3.08569815272679
,66.30463831578771
,62.41033400206221
,80.05712601988002
,10
,10
,70
,10
,30
,90
,70
,30
,70
,89.11423668645706
,92.58342391495769
,44.22604145548783
,95.42720095700402
,21.435826737054732
,19.37910846507328
,48.943206051376606
,97.68362835412275
,72.59631895251266
,63.809973321904366
,31.42076659631765
,83.88946390215908
,62.116866264263216
,16.46862820087156]


y = [7.856866949374341
,32.60533028920386
,7.9593054773530625
,97.74037355348855
,11.752247867249043
,19.38838353746982
,23.839873731365046
,13.752179944089926
,31.00629476536042
,9.428326440424428
,59.5011025964827
,73.64015636941087
,55.46780269542562
,28.89261106782417
,41.65910883295687
,2.6141574612408958
,10
,70
,10
,10
,50
,50
,10
,10
,50
,73.20222328424518
,16.76132763110746
,1.0615177467627968
,17.271594103822896
,14.310405723515663
,57.269925634522856
,82.43371784928712
,48.3488192958625
,56.325210197081134
,12.977441456959616
,59.135914263212065
,23.574727012142937
,45.42966847449507
,63.35434423882829]

plt.scatter(x,y)

plt.title('poco y para avec Matplotlib')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig('ScatterPlot_01.png')
plt.plot(x,y)
plt.show()

SUJET : faire un programme qui sert à reconnaitre des figures géométriques particulières dans un nuage de points.

1 réponse

georges97 Messages postés 13765 Date d'inscription   Statut Contributeur Dernière intervention   2 648
 

Bonjour,

doublon (à éviter)

Pourquoi ouvrir un nouveau sujet et ne pas continuer sur :

https://forums.commentcamarche.net/forum/affich-37784342-reconnaissance-de-formes-en-python

où vous avez déjà eu une réponse et une proposition d'assistance. Vous pouvez rétablir le sujet en "non résolu" en cliquant sur l'icone à cocher.

0