title: How to generate squares (randomly located, equally sized, randomly rotated) that don't intersect each other?
body: <p>I've been working on generating a layer of randomly rotated and placed squares on a 1x1 grid. I have been able to generate a single square that is randomly placed and rotated on the grid, but I'm not sure how to improve the code to generate more random squares that do not intersect with each other. Current code seen below:</p>
  
  <p><a href="https://i.stack.imgur.com/HXIrh.png" rel="nofollow noreferrer">Example of my One Randomized Square</a></p>
  
  <pre><code>from math import cos, pi, sin
  from random import randint
  from matplotlib.mlab import frange
  from matplotlib.pyplot import plot, axis, show
  
  def flake_position_layer1(): #Determines the initial position of one corner of the square
      x0 = randint(0, 100) / 100
      y0 = randint(0, 100) / 100
      theta = randint(0, 90) * pi / 180 #Angle of rotation for the square
      return x0, y0, theta
  
  
  def flake_shape(): #generates the other 3 corners of the square
      x0, y0, z, theta = flake_position_layer1()
      x1 = x0 + (0.1 * cos(theta))
      x2 = x1 + (0.1 * cos((90 * pi/180) + theta))
      x3 = x2 + (0.1 * cos((180 * pi/180) + theta))
      y1 = y0 + (0.1 * sin(theta))
      y2 = y1 + (0.1 * sin((90 * pi/180) + theta))
      y3 = y2 + (0.1 * sin((180 * pi/180) + theta))
      return x0, x1, x2, x3, y0, y1, y2, y3
  
  
  def display(): #connects the 4 corners on a plot
      x0, x1, x2, x3, y0, y1, y2, y3 = flake_shape()
      return plot([x0, x1, x2, x3, x0], [y0, y1, y2, y3, y0])
  
  
  display()
  axis([0,1,0,1]) #1x1 grid
  show()
  </code></pre>
  
  <p>I do not have a CS background (I'm an environmental engineering major) and I am extremely inexperienced with coding. Please give me any recommendations that you may have for me to try and tackle this problem with! </p>