so, you have a [quad] ((x0,y0),,,) inside a box [shape](width,height)
    
    this function gives you center [x,y], and scale factor [x,y]
    you would need to apply to [quad] in order to scale it to the same shape as the box
    
    
    !quad corners needs to be sorted like in example

def scaleToBoxParam(quad, shape):
    '''
    so, you have a [quad] ((x0,y0),,,) inside a box [shape](width,height)
    
    this function gives you center [x,y], and scale factor [x,y]
    you would need to apply to [quad] in order to scale it to the same shape as the box
    
    
    !quad corners needs to be sorted like in example
    '''
    
    #get edge middle points
    x0 = 0.5*(quad[0][0]+quad[1][0])
    x1 = 0.5*(quad[2][0]+quad[3][0])
    
    y0 = 0.5*(quad[0][1]+quad[3][1])
    y1 = 0.5*(quad[1][1]+quad[2][1])
    
    cx = (x0*shape[0]) / (x0-x1+shape[0])
    cy = (y0*shape[1]) / (y0-y1+shape[1])

    fx = abs(cx/(x0-cx))
    fy = abs(cy/(y0-cy))

    return (fx,fy), (cx,cy)