(boxes, anchors, encode_angle_to_vector=False, smooth_dim=False)
box encode for VoxelNet
    Args:
        boxes ([N, 7] Tensor): normal boxes: x, y, z, l, w, h, r
        anchors ([N, 7] Tensor): anchors
box encode for VoxelNet
    Args:
        boxes ([N, 7] Tensor): normal boxes: x, y, z, l, w, h, r
        anchors ([N, 7] Tensor): anchors
box encode for VoxelNet Args : boxes ( [ N 7 ] Tensor ) : normal boxes : x y z l w h r anchors ( [ N 7 ] Tensor ) : anchors
def second_box_encode(boxes, anchors, encode_angle_to_vector=False, smooth_dim=False):
    """box encode for VoxelNet
    Args:
        boxes ([N, 7] Tensor): normal boxes: x, y, z, l, w, h, r
        anchors ([N, 7] Tensor): anchors
    """
    box_ndim = anchors.shape[-1]
    cas, cgs = [], []
    if box_ndim > 7:
        xa, ya, za, wa, la, ha, ra, *cas = torch.split(anchors, 1, dim=-1)
        xg, yg, zg, wg, lg, hg, rg, *cgs = torch.split(boxes, 1, dim=-1)
    else:
        xa, ya, za, wa, la, ha, ra = torch.split(anchors, 1, dim=-1)
        xg, yg, zg, wg, lg, hg, rg = torch.split(boxes, 1, dim=-1)

    diagonal = torch.sqrt(la**2 + wa**2 +eps)
    xt = (xg - xa) / diagonal
    yt = (yg - ya) / diagonal
    zt = (zg - za) / ha
    cts = [g - a for g, a in zip(cgs, cas)]
    if smooth_dim:
        lt = lg / la - 1
        wt = wg / wa - 1
        ht = hg / ha - 1
    else:
        lt = torch.log(lg / la + eps)
        wt = torch.log(wg / wa + eps)
        ht = torch.log(hg / ha + eps)
    if encode_angle_to_vector:
        rgx = torch.cos(rg)
        rgy = torch.sin(rg)
        rax = torch.cos(ra)
        ray = torch.sin(ra)
        rtx = rgx - rax
        rty = rgy - ray
        return torch.cat([xt, yt, zt, wt, lt, ht, rtx, rty, *cts], dim=-1)
    else:
        rt = rg - ra
        return torch.cat([xt, yt, zt, wt, lt, ht, rt, *cts], dim=-1)
def second_box_encode ( boxes , anchors , encode_angle_to_vector = False , smooth_dim = False ) : box_ndim = anchors . shape [ - 1 ] cas , cgs = [ ] , [ ] if box_ndim > 7 : xa , ya , za , wa , la , ha , ra , * cas = torch . split ( anchors , 1 , dim = - 1 ) xg , yg , zg , wg , lg , hg , rg , * cgs = torch . split ( boxes , 1 , dim = - 1 ) else : xa , ya , za , wa , la , ha , ra = torch . split ( anchors , 1 , dim = - 1 ) xg , yg , zg , wg , lg , hg , rg = torch . split ( boxes , 1 , dim = - 1 ) diagonal = torch . sqrt ( la ** 2 + wa ** 2 + eps ) xt = ( xg - xa ) / diagonal yt = ( yg - ya ) / diagonal zt = ( zg - za ) / ha cts = [ g - a for g , a in zip ( cgs , cas ) ] if smooth_dim : lt = lg / la - 1 wt = wg / wa - 1 ht = hg / ha - 1 else : lt = torch . log ( lg / la + eps ) wt = torch . log ( wg / wa + eps ) ht = torch . log ( hg / ha + eps ) if encode_angle_to_vector : rgx = torch . cos ( rg ) rgy = torch . sin ( rg ) rax = torch . cos ( ra ) ray = torch . sin ( ra ) rtx = rgx - rax rty = rgy - ray return torch . cat ( [ xt , yt , zt , wt , lt , ht , rtx , rty , * cts ] , dim = - 1 ) else : rt = rg - ra return torch . cat ( [ xt , yt , zt , wt , lt , ht , rt , * cts ] , dim = - 1 )