from math import sqrt
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 = 1.2;
c = 1.2; d = 0.7;

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)

for i in range (1,100):
  plt.scatter(XL, YL)
  plt.gca().set_aspect('equal')
  plt.grid()
  plt.scatter(NEWXL, NEWYL, color='green')
  xo = 1 + 0.1*i; yo = 1
  x = xo/sqrt(xo**2+yo**2); y = yo/sqrt(xo**2+yo**2)
  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()
