Commit a007729c by Antoine MARTIN

### ajout inclusions_elliptiques.py

parent 25047a44
 import numpy as np import matplotlib.pyplot as plt from random import uniform def compteur(im): nn,mm=im.shape cpt=0 for i in range(nn): for j in range(mm): if im[i,j]==1: cpt=cpt+1 return cpt/nn/mm def ajoute(im,a,b,th,iso,nb): nn,mm=im.shape centers=[[0.,0.] for i in range(nb)] theta=[0. for i in range(nb)] if iso==True: for i in range(nb): theta[i]=uniform(0,np.pi) else: for i in range(nb): theta[i]=th for i in range(nb): centers[i]=[uniform(0,1),uniform(0,1)] for i in range(nb): c=max(a,b) x=centers[i][0] y=centers[i][1] the=theta[i] for j in range(int((x-c)*nn)-1,int((x+c)*nn)+1): for k in range(int((y-c)*mm)-1,int((y+c)*mm)+1): x1=(j+0.5)/nn y1=(k+0.5)/mm x2=x1*np.cos(the)+y1*np.sin(the) y2=y1*np.cos(the)-x1*np.sin(the) if (x2-x)**2/a**2+(y2-y)**2/b**2<=1: if j>=nn: l=nn else: l=0 if k>=mm: m=mm else: m=0 im[j-l,k-m]=1 def image_init(N,a,b,th,iso,f): im=np.zeros((N,N)) n=int(f/np.pi/a/b) c=0 while c
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!