code: function calc(x1, y1, x2, y2, x3, y3, x4, y4) {
    var rotate = Math.atan2(y4 - y3, x4 - x3) - Math.atan2(y2 - y1, x2 - x1)
    var scale = Math.sqrt((Math.pow(y4 - y3, 2)
      + Math.pow(x4 - x3, 2)) / (Math.pow(y2 - y1, 2)
      + Math.pow(x2 - x1, 2)))
    var translate = [
      x3
      - scale * x1 * Math.cos(rotate)
      + scale * y1 * Math.sin(rotate),
      y3
      - scale * y1 * Math.cos(rotate)
      - scale * x1 * Math.sin(rotate)]
  
    return {
      rotate: rotate,
      scale: scale,
      translate: translate,
      matrix: [
        [scale * Math.cos(rotate), -scale * Math.sin(rotate), translate[0]],
        [scale * Math.sin(rotate), scale * Math.cos(rotate), translate[1]],
        [0, 0, 1]
      ]
    }
  }
docs: calc the transform
  assume 4 points ABCD on the coordinate system
  > rotate：angle rotating from AB to CD
  > scale：scale ratio from AB to CD
  > translate：translate shift from A to C
  
  @param  {number} x1 abscissa of A
  @param  {number} y1 ordinate of A
  @param  {number} x2 abscissa of B
  @param  {number} y2 ordinate of B
  @param  {number} x3 abscissa of C
  @param  {number} y3 ordinate of C
  @param  {number} x4 abscissa of D
  @param  {number} y4 ordinate of D
  @return {object}    transform object like
  {rotate, scale, translate[2], matrix[3][3]}