title: Rotate, scale and translate 2D coordinates?
body: <p>I'm am working on a project at the moment where I am trying to create a Hilbert curve using the Python Imaging Library. I have created a function which will generate new coordinates for the curve through each iteration and place them into various lists which then I want to be able to move, rotate and scale. I was wondering if anyone could give me some tips or a way to do this as I am completely clueless. Still working on the a lot of the code.</p>
  
  <pre><code>#! usr/bin/python
  import Image, ImageDraw
  import math
  
  # Set the starting shape
  img = Image.new('RGB', (1000, 1000))
  draw = ImageDraw.Draw(img)
  
  curve_X = [0, 0, 1, 1]
  curve_Y = [0, 1, 1, 0]
  
  combinedCurve = zip(curve_X, curve_Y)
  draw.line((combinedCurve), fill=(220, 255, 250))
  iterations = 5
  
  # Start the loop
  for i in range(0, iterations):
      # Make 4 copies of the curve
  
      copy1_X = list(curve_X)
      copy1_Y = list(curve_Y)
  
      copy2_X = list(curve_X)
      copy2_Y = list(curve_Y)
  
      copy3_X = list(curve_X)
      copy3_Y = list(curve_Y)
  
      copy4_X = list(curve_X)
      copy4_Y = list(curve_Y)
  
      # For copy 1, rotate it by 90 degree clockwise
      # Then move it to the bottom left
      # For copy 2, move it to the top left
      # For copy 3, move it to the top right
      # For copy 4, rotate it by 90 degrees anticlockwise
      # Then move it to the bottom right
  
      # Finally, combine all the copies into a big list
      combinedCurve_X = copy1_X + copy2_X + copy3_X + copy4_X
      combinedCurve_Y = copy1_Y + copy2_Y + copy3_Y + copy4_Y
  
  # Make the initial curve equal to the combined one
  curve_X = combinedCurve_X[:]
  curve_Y = combinedCurve_Y[:]
  
  # Repeat the loop
  
  # Scale it to fit the canvas
  curve_X = [x * xSize for x in curve_X]
  curve_Y = [y * ySize for y in curve_Y]
  # Draw it with something that connects the dots
  curveCoordinates = zip(curve_X, curve_Y)
  draw.line((curveCoordinates), fill=(255, 255, 255))
  
  img2=img.rotate(180)
  img2.show()
  </code></pre>