From 21e1d2a10c7cd9f07371803f8624d034bfcf227a Mon Sep 17 00:00:00 2001
From: DylanVsn <43576618+DylanVsn@users.noreply.github.com>
Date: Wed, 29 Jan 2020 13:38:50 +0100
Subject: [PATCH] =?UTF-8?q?ok=20j'avais=20oubli=C3=A9=20un=20fichier?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
3/TP3_voisin.py | 193 ++++++++++
3/__pycache__/argparse.cpython-38.pyc | Bin 0 -> 759 bytes
3/argtest.py | 18 +
3/pts.txt | 500 ++++++++++++++++++++++++++
3/test_plot.py | 48 +++
3/énoncé.txt | 47 +++
6 files changed, 806 insertions(+)
create mode 100755 3/TP3_voisin.py
create mode 100644 3/__pycache__/argparse.cpython-38.pyc
create mode 100755 3/argtest.py
create mode 100644 3/pts.txt
create mode 100644 3/test_plot.py
create mode 100644 3/énoncé.txt
diff --git a/3/TP3_voisin.py b/3/TP3_voisin.py
new file mode 100755
index 0000000..7a1f6b7
--- /dev/null
+++ b/3/TP3_voisin.py
@@ -0,0 +1,193 @@
+#!/usr/bin/env python3
+import sys, os
+import matplotlib.pyplot as plt
+from random import random, choice
+import numpy as np
+from time import sleep
+import argparse
+
+"""
+ MNI TP3 - 27 janvier 2020
+ Dylan Voisin - M1 Informatique Luminy
+ Franck Palacios - M1 Informatique Luminy
+
+ Notes:
+ - u1 et u2 ne semblent pas orthogonaux, ceci est dû à la non utilisation
+ d'une échelle 1:1 pour l'affichage des points
+ - u1 et u2 ne sont pas proportionnels par rapport à lambda mais à la
+ distance entre le barycentre et le point le plus éloigné selon la
+ composante x ou y
+ - u1 est orienté «vers la droite» et u2 «vers le haut» dans ce programme
+"""
+
+
+def acquérir_depuis_fichier(filename):
+ # l_pts = []
+ # with open(filename) as f:
+ # for line in f:
+ # split = line.split()
+ # if len(split) == 2:
+ # l_pts.append(list(map(float, split)))
+ # return np.array(l_pts)
+ return np.loadtxt(filename)
+
+def calc_barycentre(l_pts):
+ x = sum(l_pts[:,0]) / len(l_pts)
+ y = sum(l_pts[:,1]) / len(l_pts)
+ return x, y
+
+def centrer_points(l_pts, barycentre):
+ return l_pts - barycentre
+
+def calc_matrice_corrélation(l_pts):
+ c_pts = centrer_points(l_pts, calc_barycentre(l_pts))
+ A = np.array([
+ [sum(pt[0] ** 2 for pt in c_pts), sum(pt[0] * pt[1] for pt in c_pts)],
+ [sum(pt[0] * pt[1] for pt in c_pts), sum(pt[1] ** 2 for pt in c_pts)]
+ ])
+ return A
+
+def diagonaliser_matrice22(m):
+ a, b, c, d = m[0][0], m[0][1], m[1][0], m[1][1]
+ discr = (-d - a) ** 2 - 4 * (a * d - b**2)
+ lambda1 = ((d + a) + discr ** .5) / 2
+ lambda2 = ((d + a) - discr ** .5) / 2
+ if lambda1 != 0:
+ if a - lambda1 != 0 and b != 0:
+ u1 = np.array([-b, (a-lambda1)])
+ u1 *= -1 if b > 0 else 1
+ else:
+ u1 = np.array([lambda1, 0])
+ u2 = np.array([-u1[1], u1[0]])
+ else:
+ if a - lambda2 != 0 and b != 0:
+ u2 = np.array([-b, (a-lambda2)])
+ u2 *= -1 if b < 0 else 1
+ else:
+ u2 = np.array([lambda2, 0])
+ u1 = np.array([u2[1], -u2[0]])
+ return u1, u2, lambda1, lambda2
+
+def get_info_affichage(l_pts):
+ """renvoie les vecteurs u1 et u2 pour l'affichage ainsi que xmin, xmax, ymin, ymax"""
+ bary = calc_barycentre(l_pts)
+ u1, u2 = diagonaliser_matrice22(calc_matrice_corrélation(l_pts))[:2]
+ dist = min(max(l_pts[:,0]) - bary[0], max(l_pts[:,1]) - bary[1])
+ dist_x = max(l_pts[:,0]) - min(l_pts[:,0])
+ dist_y = max(l_pts[:,1]) - min(l_pts[:,1])
+ x_range = min(l_pts[:,0]) - 0.1 * dist_x, max(l_pts[:,0]) + 0.1 * dist_x
+ y_range = min(l_pts[:,1]) - 0.1 * dist_y, max(l_pts[:,1]) + 0.1 * dist_y
+ u1 = u1 / np.linalg.norm(u1) * dist
+ u2 = u2 / np.linalg.norm(u2) * 1/2 * dist
+ return u1, u2, x_range, y_range, dist
+
+
+def visualiser_nuage(l_pts):
+ bary = calc_barycentre(l_pts)
+ u1, u2 = diagonaliser_matrice22(calc_matrice_corrélation(l_pts))[:2]
+ dist = min(max(l_pts[:,0]) - bary[0], max(l_pts[:,1]) - bary[1])
+ u1 = u1 / np.linalg.norm(u1) * dist
+ u2 = u2 / np.linalg.norm(u2) * 1/2 * dist
+ ax = plt.axes()
+ # plot du nuage
+ plt.scatter(l_pts[:,0], l_pts[:,1])
+ ax.arrow(*bary, *u1, head_length=0.1*dist, head_width=0.1*dist, ec="black", fc="white")
+ ax.arrow(*bary, *u2, head_length=0.1*dist, head_width=0.1*dist, ec="black", fc="white")
+ # ax.set_aspect('equal')
+ plt.show()
+
+def animation_nuage(l_pts, loops=10, time_sleep=2, delta_bruit=3):
+ plt.ion()
+ fig = plt.figure()
+ ax = fig.add_subplot(111)
+ fig.canvas.draw()
+ # nuage courant (pas de do while en Python)
+ bary = calc_barycentre(l_pts)
+ u1, u2, x_range, y_range, dist = get_info_affichage(l_pts)
+ sc = ax.scatter(l_pts[:,0], l_pts[:,1])
+ arr1 = ax.arrow(*bary, *u1, head_length=0.1*dist, head_width=0.1*dist, ec="black", fc="white")
+ arr2 = ax.arrow(*bary, *u2, head_length=0.1*dist, head_width=0.1*dist, ec="black", fc="white")
+ plt.title("itération 0")
+ fig.canvas.flush_events()
+ fig.canvas.draw()
+ fig.canvas.flush_events()
+ sleep(time_sleep) # attente avant animation suivante
+ for i in range(loops):
+ plt.title("itération " + str(i+1))
+ # aléa
+ ran = np.random.random(l_pts.shape) * 2 * delta_bruit - delta_bruit
+ l_pts += ran
+ # recalcul des données
+ bary = calc_barycentre(l_pts)
+ u1, u2, x_range, y_range, dist = get_info_affichage(l_pts)
+ ax.set_xlim(*x_range)
+ ax.set_ylim(*y_range)
+ # plot
+ sc.set_offsets(l_pts) # repositionnement des points
+ arr1.remove() # on enlève les vecteurs
+ arr2.remove()
+ arr1 = ax.arrow(*bary, *u1, head_length=0.1*dist, head_width=0.1*dist, ec="black", fc="white")
+ arr2 = ax.arrow(*bary, *u2, head_length=0.1*dist, head_width=0.1*dist, ec="black", fc="white")
+ fig.canvas.flush_events()
+ fig.canvas.draw() # on redessine
+ fig.canvas.flush_events()
+ sleep(time_sleep) # attente avant animation suivante
+
+
+def main(argv):
+ parser = argparse.ArgumentParser()
+ gps = parser.add_mutually_exclusive_group(required=True)
+ parser.add_argument("-i", "--input",
+ help="input file for dots - if none, generate dots")
+ gps.add_argument("-s", "--show", action="store_true",
+ help="show cloud of dots with u1 and u2")
+ gps.add_argument("-l", "--loop", type=int, default=10,
+ help="number of loop to show/perform on randomized dots from originals ones")
+ parser.add_argument("-d", "--delay", type=float, default=2,
+ help="amount of time between each loop")
+ parser.add_argument("-n", "--noise", type = float, default=10,
+ help="maximum value of the noise applied between each step")
+ if not argv:
+ parser.print_usage()
+ sys.exit(0)
+ args = parser.parse_args(argv)
+ if args.input:
+ if not os.path.isfile(args.input):
+ print("File", args.input, "not found.", file=sys.stderr)
+ sys.exit(1)
+ else:
+ l_pts = acquérir_depuis_fichier(args.input)
+ else:
+ l_pts = []
+ n = 500 # nombre de points
+ f = lambda x: x/2 + 3 # fonction génératrice de la ditribution
+ delta_bruit = 10 # bruit généré, 0 si on en veut aucun
+ for i in range(n):
+ y = f(i) + choice((-1, 1)) * random() * delta_bruit/2
+ l_pts.append([i, y])
+ l_pts = np.array(l_pts)
+ if args.show:
+ visualiser_nuage(l_pts)
+ elif args.loop:
+ animation_nuage(l_pts, args.loop, args.delay, args.noise)
+
+
+
+if __name__ == "__main__":
+ # if len(sys.argv) == 2:
+ # l_pts = acquérir_depuis_fichier(sys.argv[1])
+ # else:
+ # l_pts = []
+ # n = 500 # nombre de points
+ # f = lambda x: x/2 + 3 # fonction génératrice de la ditribution
+ # delta_bruit = 10 # bruit généré, 0 si on en veut aucun
+ # for i in range(n):
+ # y = f(i) + choice((-1, 1)) * random() * delta_bruit/2
+ # l_pts.append([i, y])
+ # l_pts = np.array(l_pts)
+ # # np.savetxt("pts.txt", l_pts, "%f")
+ # u1, u2 = diagonaliser_matrice22(calc_matrice_corrélation(l_pts))[:2]
+ # # print(f"{u1/np.linalg.norm(u1)=}\n{u2/np.linalg.norm(u2)=}")
+ # visualiser_nuage(l_pts)
+ # animation_nuage(l_pts, 20, delta_bruit=100)
+ main(sys.argv[1:])
diff --git a/3/__pycache__/argparse.cpython-38.pyc b/3/__pycache__/argparse.cpython-38.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..abb6b4080ec5f174e2b51ead9845a009433f9c73
GIT binary patch
literal 759
zcmZ8fJ#Q015Z$}8&lkr|AV^dci$r57=9HwNK!^xI86hDkTyWZW#`ePA?rA@g_$mt8
z{0FDxFKtUjPn8CCFA<5@)4tKXnRzoix{u@Wkc4ynsr>vqCFEyx?w>q3ufsLp0|0?U
zkQu=Q(yyuhhGdgoky(b>rWb4<`
#e1b+YpY{3w=FMEM0
z0yBa!4q*p&|1l5XA#TIoEt73VIKE0|JCJ-JlSjY8B;>>wRaG-CtEx?>yd6xZTsF?O
z`<&cQ{FX&gPaYsk1OwP!dr|DAlxYrK?X-$I9qat7z0K8`NR6
znkq?kP*F8+5pKj6S_NM7C6`Q?kbx$2=-G9sxz&gGSU|znEoHTG(#8gs*GNy%o+C<%
zY`*GRPIi64^s-^vVBDBwHCC11Io3;8qqOg1K>NH)(EbSnsA^{&6JlNA#auYU+o*
z@qdw!(`u;*FX8o{h5i5=F1w8A}{2=;qSX&3z2jxoD
zSPEQQRi5C5?G|6YJAPA|7iBGZX`Aw>4Aq_3^JeXfm$d>X@KyMEiFp>FNQ>m|OaJ8Q
IF!>+<0%GRsX8-^I
literal 0
HcmV?d00001
diff --git a/3/argtest.py b/3/argtest.py
new file mode 100755
index 0000000..0861f73
--- /dev/null
+++ b/3/argtest.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+import argparse
+import sys
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ gps = parser.add_mutually_exclusive_group(required=True)
+ parser.add_argument("-i", "--input",
+ help="input file for dots - if none, generate dots")
+ gps.add_argument("-s", "--show", action="store_true",
+ help="show cloud of dots with u1 and u2")
+ gps.add_argument("-l", "--loop", type=int,
+ help="number of loop to show/perform on randomized dots from originals ones")
+ parser.add_argument("-d", "--delay", type=float,
+ help="amount of time between each loop")
+ parser.add_argument("-n", "--noise", type = float,
+ help="maximum value of the noise applied between each step")
+ # parser.print_usage()
+ args = parser.parse_args(sys.argv[1:])
\ No newline at end of file
diff --git a/3/pts.txt b/3/pts.txt
new file mode 100644
index 0000000..3898cca
--- /dev/null
+++ b/3/pts.txt
@@ -0,0 +1,500 @@
+0.000000 -0.023186
+1.000000 5.857825
+2.000000 3.275455
+3.000000 3.401954
+4.000000 8.635886
+5.000000 10.377725
+6.000000 7.556466
+7.000000 10.770253
+8.000000 7.524395
+9.000000 5.171486
+10.000000 8.546169
+11.000000 12.289386
+12.000000 13.900921
+13.000000 7.927590
+14.000000 9.845790
+15.000000 7.187358
+16.000000 9.253599
+17.000000 12.145586
+18.000000 13.537859
+19.000000 12.393378
+20.000000 13.145255
+21.000000 17.496613
+22.000000 17.940572
+23.000000 11.101478
+24.000000 19.047264
+25.000000 11.185974
+26.000000 15.039941
+27.000000 21.059292
+28.000000 19.136668
+29.000000 22.281619
+30.000000 19.810588
+31.000000 15.961196
+32.000000 15.521450
+33.000000 22.426298
+34.000000 23.347813
+35.000000 16.800230
+36.000000 20.916651
+37.000000 26.095866
+38.000000 20.932527
+39.000000 19.815266
+40.000000 19.746754
+41.000000 19.190824
+42.000000 28.586348
+43.000000 21.292743
+44.000000 26.050123
+45.000000 26.939175
+46.000000 28.266101
+47.000000 27.055208
+48.000000 28.494551
+49.000000 28.805590
+50.000000 30.667429
+51.000000 31.778983
+52.000000 27.385029
+53.000000 31.090957
+54.000000 25.837646
+55.000000 27.512875
+56.000000 27.284538
+57.000000 28.027620
+58.000000 33.654044
+59.000000 37.117874
+60.000000 37.573314
+61.000000 38.294268
+62.000000 38.636872
+63.000000 30.152789
+64.000000 39.979247
+65.000000 33.321116
+66.000000 38.087786
+67.000000 38.494769
+68.000000 40.620081
+69.000000 34.428033
+70.000000 42.203396
+71.000000 40.970667
+72.000000 43.442315
+73.000000 43.870836
+74.000000 44.377727
+75.000000 37.162640
+76.000000 36.647850
+77.000000 43.537719
+78.000000 37.877693
+79.000000 44.043660
+80.000000 46.546596
+81.000000 43.304593
+82.000000 42.963059
+83.000000 42.108888
+84.000000 43.919368
+85.000000 46.041826
+86.000000 50.902350
+87.000000 45.677434
+88.000000 49.690260
+89.000000 47.792927
+90.000000 49.775464
+91.000000 52.192190
+92.000000 52.490735
+93.000000 48.090169
+94.000000 46.980611
+95.000000 53.643081
+96.000000 52.401143
+97.000000 56.300351
+98.000000 55.682241
+99.000000 55.569692
+100.000000 54.116217
+101.000000 53.499871
+102.000000 51.147650
+103.000000 56.830054
+104.000000 53.411645
+105.000000 57.874685
+106.000000 57.007126
+107.000000 59.778208
+108.000000 53.925589
+109.000000 59.952021
+110.000000 62.508451
+111.000000 57.788687
+112.000000 62.375443
+113.000000 58.311711
+114.000000 58.121713
+115.000000 59.810022
+116.000000 61.746637
+117.000000 65.825080
+118.000000 63.333089
+119.000000 58.763863
+120.000000 67.109977
+121.000000 64.998450
+122.000000 67.688598
+123.000000 64.986981
+124.000000 63.008893
+125.000000 69.070582
+126.000000 65.717463
+127.000000 70.299678
+128.000000 64.840769
+129.000000 68.343514
+130.000000 72.704847
+131.000000 70.048405
+132.000000 73.786231
+133.000000 68.499069
+134.000000 71.214015
+135.000000 71.019498
+136.000000 71.148099
+137.000000 69.342111
+138.000000 71.383217
+139.000000 71.012142
+140.000000 76.566695
+141.000000 69.486149
+142.000000 71.402444
+143.000000 71.483227
+144.000000 71.759510
+145.000000 74.985333
+146.000000 73.188678
+147.000000 72.620426
+148.000000 73.081873
+149.000000 77.713553
+150.000000 79.300275
+151.000000 82.473757
+152.000000 75.324889
+153.000000 83.748924
+154.000000 80.007542
+155.000000 80.282210
+156.000000 82.747910
+157.000000 86.457627
+158.000000 83.420580
+159.000000 86.066021
+160.000000 87.999092
+161.000000 85.212865
+162.000000 86.152684
+163.000000 83.713905
+164.000000 89.806113
+165.000000 88.863127
+166.000000 83.747370
+167.000000 85.729469
+168.000000 90.278674
+169.000000 87.186322
+170.000000 90.664731
+171.000000 89.789554
+172.000000 85.059321
+173.000000 92.954290
+174.000000 91.984821
+175.000000 92.528039
+176.000000 86.062650
+177.000000 88.554582
+178.000000 89.026777
+179.000000 89.494510
+180.000000 95.203395
+181.000000 94.680597
+182.000000 98.671727
+183.000000 92.458947
+184.000000 92.550664
+185.000000 93.584651
+186.000000 96.529280
+187.000000 91.510190
+188.000000 101.329778
+189.000000 97.326805
+190.000000 93.963321
+191.000000 101.788415
+192.000000 94.844023
+193.000000 98.012377
+194.000000 99.862506
+195.000000 104.929017
+196.000000 105.511555
+197.000000 104.173418
+198.000000 106.219756
+199.000000 99.196912
+200.000000 104.983239
+201.000000 105.612156
+202.000000 105.198355
+203.000000 108.664667
+204.000000 104.347114
+205.000000 108.862571
+206.000000 102.206320
+207.000000 105.512305
+208.000000 108.495640
+209.000000 104.686030
+210.000000 107.205950
+211.000000 109.056544
+212.000000 105.144668
+213.000000 110.019114
+214.000000 111.246693
+215.000000 114.697784
+216.000000 107.669608
+217.000000 111.021809
+218.000000 112.559574
+219.000000 115.881233
+220.000000 117.420091
+221.000000 117.527731
+222.000000 110.604158
+223.000000 119.310637
+224.000000 116.041797
+225.000000 118.162028
+226.000000 112.911618
+227.000000 114.921596
+228.000000 112.282852
+229.000000 121.759767
+230.000000 113.923272
+231.000000 119.552405
+232.000000 118.887070
+233.000000 122.143651
+234.000000 116.990503
+235.000000 125.228443
+236.000000 124.042265
+237.000000 126.339659
+238.000000 118.799490
+239.000000 124.482421
+240.000000 123.178900
+241.000000 121.283397
+242.000000 127.043408
+243.000000 127.300764
+244.000000 120.651027
+245.000000 123.519724
+246.000000 130.666442
+247.000000 130.898628
+248.000000 122.351916
+249.000000 131.201379
+250.000000 126.485689
+251.000000 125.279486
+252.000000 133.619459
+253.000000 131.267522
+254.000000 132.832665
+255.000000 130.486150
+256.000000 127.254321
+257.000000 135.538334
+258.000000 130.900252
+259.000000 136.868751
+260.000000 135.563387
+261.000000 132.244797
+262.000000 138.675247
+263.000000 139.047895
+264.000000 133.845300
+265.000000 140.018995
+266.000000 137.165498
+267.000000 135.177485
+268.000000 134.310194
+269.000000 140.809078
+270.000000 137.061594
+271.000000 139.601021
+272.000000 142.928305
+273.000000 142.447830
+274.000000 136.899126
+275.000000 138.108276
+276.000000 140.870780
+277.000000 136.562717
+278.000000 141.404804
+279.000000 147.424077
+280.000000 139.761758
+281.000000 140.529338
+282.000000 147.305599
+283.000000 145.368309
+284.000000 140.853087
+285.000000 147.523410
+286.000000 143.026952
+287.000000 148.390897
+288.000000 149.905700
+289.000000 144.663978
+290.000000 145.724384
+291.000000 147.469167
+292.000000 151.643445
+293.000000 153.741733
+294.000000 151.694803
+295.000000 149.082852
+296.000000 148.196089
+297.000000 148.974733
+298.000000 154.583509
+299.000000 147.667948
+300.000000 148.956661
+301.000000 157.204923
+302.000000 153.023764
+303.000000 156.134042
+304.000000 158.103629
+305.000000 159.174416
+306.000000 155.526722
+307.000000 158.485125
+308.000000 152.925946
+309.000000 152.636507
+310.000000 153.340815
+311.000000 156.037289
+312.000000 159.765266
+313.000000 159.756521
+314.000000 161.665146
+315.000000 162.896407
+316.000000 160.826469
+317.000000 161.637394
+318.000000 166.256212
+319.000000 166.675814
+320.000000 164.744009
+321.000000 165.130178
+322.000000 166.428968
+323.000000 165.395637
+324.000000 168.708113
+325.000000 165.036089
+326.000000 167.818445
+327.000000 169.983339
+328.000000 169.754200
+329.000000 164.279482
+330.000000 172.741400
+331.000000 165.361264
+332.000000 167.270205
+333.000000 174.115172
+334.000000 173.130451
+335.000000 174.164707
+336.000000 172.788950
+337.000000 166.513022
+338.000000 176.437103
+339.000000 174.051857
+340.000000 169.727935
+341.000000 178.125984
+342.000000 175.480246
+343.000000 173.659685
+344.000000 171.406731
+345.000000 174.030876
+346.000000 177.406337
+347.000000 179.125218
+348.000000 174.451141
+349.000000 179.924812
+350.000000 180.938294
+351.000000 183.457166
+352.000000 176.240022
+353.000000 177.460583
+354.000000 177.002543
+355.000000 183.156108
+356.000000 179.717521
+357.000000 178.123057
+358.000000 179.211013
+359.000000 185.724378
+360.000000 179.370959
+361.000000 183.285567
+362.000000 187.511417
+363.000000 187.850589
+364.000000 184.396539
+365.000000 182.186636
+366.000000 188.189620
+367.000000 183.413501
+368.000000 184.271037
+369.000000 189.968678
+370.000000 192.305016
+371.000000 189.502416
+372.000000 190.098525
+373.000000 190.704332
+374.000000 192.102748
+375.000000 189.686660
+376.000000 194.841209
+377.000000 192.983384
+378.000000 190.573300
+379.000000 195.777848
+380.000000 197.049596
+381.000000 188.911269
+382.000000 197.517406
+383.000000 195.254899
+384.000000 195.894990
+385.000000 190.714046
+386.000000 196.972954
+387.000000 197.940654
+388.000000 192.154845
+389.000000 195.568697
+390.000000 198.092042
+391.000000 202.679041
+392.000000 202.708740
+393.000000 204.425199
+394.000000 204.988617
+395.000000 195.902325
+396.000000 201.400919
+397.000000 202.658805
+398.000000 205.857207
+399.000000 199.419748
+400.000000 201.427236
+401.000000 203.995188
+402.000000 207.941074
+403.000000 208.089890
+404.000000 201.548774
+405.000000 209.628258
+406.000000 202.455859
+407.000000 207.627638
+408.000000 211.495012
+409.000000 207.295396
+410.000000 204.540182
+411.000000 209.965521
+412.000000 210.181387
+413.000000 206.685494
+414.000000 206.025939
+415.000000 209.866913
+416.000000 210.860974
+417.000000 211.728698
+418.000000 213.717862
+419.000000 210.439357
+420.000000 215.479076
+421.000000 215.634002
+422.000000 216.605436
+423.000000 218.320341
+424.000000 219.527144
+425.000000 214.317575
+426.000000 218.507562
+427.000000 212.526802
+428.000000 218.575654
+429.000000 218.720838
+430.000000 215.690194
+431.000000 217.063122
+432.000000 221.622172
+433.000000 218.980454
+434.000000 223.650525
+435.000000 217.440217
+436.000000 218.405068
+437.000000 220.511432
+438.000000 225.659634
+439.000000 227.044015
+440.000000 223.236470
+441.000000 226.537748
+442.000000 224.199055
+443.000000 222.451859
+444.000000 224.367010
+445.000000 225.417304
+446.000000 223.140206
+447.000000 222.295442
+448.000000 226.364948
+449.000000 224.560386
+450.000000 228.166792
+451.000000 228.041655
+452.000000 225.874816
+453.000000 232.871836
+454.000000 230.252569
+455.000000 225.680708
+456.000000 235.503221
+457.000000 230.235137
+458.000000 228.079254
+459.000000 235.149751
+460.000000 234.942090
+461.000000 236.538539
+462.000000 232.444580
+463.000000 232.682806
+464.000000 236.449077
+465.000000 240.450187
+466.000000 231.817796
+467.000000 233.797735
+468.000000 238.428645
+469.000000 232.974698
+470.000000 242.508818
+471.000000 241.510247
+472.000000 237.983061
+473.000000 241.859439
+474.000000 238.537365
+475.000000 236.777731
+476.000000 243.076036
+477.000000 244.868494
+478.000000 243.871791
+479.000000 246.684833
+480.000000 246.219329
+481.000000 241.248741
+482.000000 247.262100
+483.000000 241.143280
+484.000000 243.979801
+485.000000 240.505642
+486.000000 244.799621
+487.000000 250.435008
+488.000000 250.566914
+489.000000 249.690288
+490.000000 252.775043
+491.000000 244.099934
+492.000000 252.674239
+493.000000 244.622387
+494.000000 249.923331
+495.000000 245.664379
+496.000000 249.643069
+497.000000 249.658142
+498.000000 253.746202
+499.000000 247.520508
diff --git a/3/test_plot.py b/3/test_plot.py
new file mode 100644
index 0000000..819d68b
--- /dev/null
+++ b/3/test_plot.py
@@ -0,0 +1,48 @@
+import numpy as np
+import matplotlib.pyplot as plt
+from time import sleep
+
+# internet
+# import matplotlib.pyplot as plt
+# import numpy as np
+
+# x = np.linspace(0, 6*np.pi, 100)
+# y = np.sin(x)
+
+# # You probably won't need this if you're embedding things in a tkinter plot...
+# plt.ion()
+
+# fig = plt.figure()
+# ax = fig.add_subplot(111)
+# line1, = ax.plot(x, y, 'r-') # Returns a tuple of line objects, thus the comma
+
+# for phase in np.linspace(0, 10*np.pi, 500):
+# line1.set_ydata(np.sin(x + phase))
+# fig.canvas.draw()
+# fig.canvas.flush_events()
+# fin internet
+
+x = np.arange(0, 10, 0.01)
+y = np.cos(x)
+
+plt.ion()
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+
+# l1 = ax.plot(x, y)[0]
+
+l = ax.plot(x, y)[0]
+ax.set_xlim(0, 10)
+ax.set_ylim(-2, 10)
+arr = ax.arrow(0, 0, 0, 0)
+for i in range(10):
+ arr.remove()
+ # plt.clf()
+ l.set_ydata(np.cos(x+i))
+ arr = ax.arrow(i, 0, 1, 1)
+ fig.canvas.draw()
+ fig.canvas.flush_events()
+ sleep(1)
+
+# ax = plt.axes()
\ No newline at end of file
diff --git a/3/énoncé.txt b/3/énoncé.txt
new file mode 100644
index 0000000..4ed7e48
--- /dev/null
+++ b/3/énoncé.txt
@@ -0,0 +1,47 @@
+envoyer à Jean Sequeira TP3_.py
+
+1) Acquérir des points 2D (fichier ou dans le programme)
+
+2) Calculer le barycentre G
+
+3) Calculer la matrice de corrélation A
+| sum{x_i²} sum{x_i*y_i} |
+| sum{x_i*y_i} sum{y_i²} |
+x_i, y_i en coordonnées centrées
+
+4) Diagonaliser A → lambda1 et lambda2 (lambda1 ≥ lambda2)
+ u_1 et u2
+
+5) Visualiser les points et le repère (G, u_1, u_2)
+
+6) Faire évoluer le jeu de points en les déplaçant aléatoirement (dans le
+voisinage de leur position précédente)
+
+
+-------------------------------------------------------------------------------
+ce qu'on doit remettre avant dimanche:
+programme python par courriel, mettre en copie de ce mail les autres membres du
+groupe
+le nom du prgm TP3_.py # nom de celui qui envoie par exemple
+pas de zip
+
+contenu du tp:
+récupérer des pts depuis un fichier
+calculer le barycentre de tous ces pts (moyenne des coordonnées des points)
+
+calculer matrice corrélation, somme des x et y de TOUS LES POINTS MOINS COORD
+BARYCENTRE (coordonnées centrées au barycentre)
+
+diagonaliser la matrice A obtenue précédemment (résolution équation second degré)
+matrice symétrique définie ??? mais toujours 2 solutions
+
+on récupère u1 et u2
+
+et on va visualiser les points avec le nouveau repère
+
+le prof a fait varier u1 et u2 en fonction des valeurs propres pour qu'ils ne
+soient pas unitaires
+(u2 - rotation de 90° de u1)
+
+boucle avec le random et le refresh de la fenêtre avec les nouveau vecteurs et
+repères résultants des nouveaux points générés
\ No newline at end of file