from math import sqrt, cos, sin
from random import random
import matplotlib.pyplot as plt

XL = []; YL = []
for i in range(1000):
  x = random()-0.5
  y = random()-0.5
  X = x/sqrt(x**2 + y**2)
  Y = y/sqrt(x**2 + y**2)
  XL.append (X)
  YL.append (Y)

# 
#  /     \   /   \    /         \
#  | a b | * | x |  = | xa + yb |
#  | c d |   | y |    | xc + yd |
#  \     /   \   /    \         /

a = 1  ; b = 0  ;
c = 0  ; d = 0  ;

NEWXL = []; NEWYL = []
for (x,y) in zip (XL, YL):
  newx = x*a + y*b
  newy = x*c + y*d
  NEWXL.append (newx)
  NEWYL.append (newy)

# merci Natt et toute la promotion Polytech Dijon 2025, ILIA

for grossθ in range (0, 80, 1):
  θ = grossθ / 10
  plt.scatter(XL, YL)
  plt.gca().set_aspect('equal')
  plt.grid()
  plt.scatter(NEWXL, NEWYL, color='green')
  
  x = cos (θ)
  y = sin (θ)
  plt.plot([0,x], [0,y], color='red', linewidth=8)
  
  newx = x*a + y*b; newy = x*c + y*d
  plt.plot([0,newx], [0,newy], color='black')
  plt.show()
