矩形外接矩形-内部矩形的大小

问题描述 投票:0回答:1

假设我有一个外接另一个矩形的矩形。我仅有的参数是X大小,Y大小和R-内部矩形的边之比。

enter image description here

是否可以找到L的大小(意味着内部矩形的一侧的大小?)如果是这样,正确的公式是什么?

python image-processing rectangles bounding-box
1个回答
0
投票

嗯,这是python中的解决方案:

  1. 如何找到角度
  2. 如何找到L
def diagonal_calc(row):

    #parameters I have
    R = 1/(row.lw_ratio) 
    X = row.x_size
    Y = row.y_size

    #calculations

    #find alpha:
    equation1 = (((X/Y)*R)-1) / (R-(X/Y))
    alpha = math.degrees(math.tan(equation1))

    #find sides:
    sin_alpha = R*math.sin(np.deg2rad(alpha))
    cos_alpha = math.cos(np.deg2rad(alpha))

    L_side = X/((R*sin_alpha)  +  cos_alpha)
    RL_side = R*L_side


    return alpha, L_side, RL_side
© www.soinside.com 2019 - 2024. All rights reserved.