voilà on peut mettre des fonctions

This commit is contained in:
DylanVsn 2020-01-29 13:48:50 +01:00
parent 21e1d2a10c
commit 7c3a300947
2 changed files with 9 additions and 4 deletions

View File

@ -137,8 +137,13 @@ def animation_nuage(l_pts, loops=10, time_sleep=2, delta_bruit=3):
def main(argv):
parser = argparse.ArgumentParser()
gps = parser.add_mutually_exclusive_group(required=True)
parser.add_argument("-i", "--input",
gpi = parser.add_mutually_exclusive_group(required=True)
gpi.add_argument("-i", "--input",
help="input file for dots - if none, generate dots")
gpi.add_argument("-f", "--function",
help="function to use to generate dots, ex -f 3*x+4")
parser.add_argument("-N", "--nb-dots", type=int, default=500,
help="number of dots to generate (from 0 to NB_DOTS) from function")
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,
@ -159,9 +164,9 @@ def main(argv):
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
n = args.nb_dots # nombre de points
f = lambda x: eval(args.function) # fonction génératrice de la ditribution
delta_bruit = 0 # 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])