// File: GouMinghao[P]graspnms/./geo.cpp
// Function: viewpoint_params_to_matrix(double, double, double, double)
Mat3x3 viewpoint_params_to_matrix(double appx,double appy,double appz,double angle)
{
    //appx is the x component of apporaching vector
    vector<double> axis_x,axis_y,axis_z;
    Mat3x3 R1,R2;
    axis_x = normal_form(get_vector_3(appx,appy,appz));
    axis_y = get_vector_3(-axis_x[1],axis_x[0],0);
    if(norm(axis_y) == 0) {
        axis_y = get_vector_3(0,1,0);
    }
    else {
        axis_y = normal_form(axis_y);
    }
    axis_z = cross(axis_x,axis_y);
    R1 = Mat3x3
    (
        get_vector_3(1,0,0),
        get_vector_3(0,cos(angle),-sin(angle)),
        get_vector_3(0,sin(angle),cos(angle)),
        0
    );
    R2 = Mat3x3
    (
        axis_x,
        axis_y,
        axis_z,
        1
    );
    return R2.matmul(R1);

    /* # axis_x = towards
    # axis_y = np.array([-axis_x[1], axis_x[0], 0])
    # axis_x = axis_x / np.linalg.norm(axis_x)
    # axis_y = axis_y / np.linalg.norm(axis_y)
    # axis_z = np.cross(axis_x, axis_y)
    # R1 = np.array([[1, 0, 0],
    #             [0, np.cos(angle), -np.sin(angle)],
    #             [0, np.sin(angle), np.cos(angle)]])
    # R2 = np.c_[axis_x, np.c_[axis_y, axis_z]]
    # matrix = R2.dot(R1)
    # return matrix.astype(np.float32) */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x410, %rsp            # imm = 0x410
movq %rdi, -0x380(%rbp)
movq %rdi, -0x378(%rbp)
movsd %xmm0, -0x8(%rbp)
movsd %xmm1, -0x10(%rbp)
movsd %xmm2, -0x18(%rbp)
movsd %xmm3, -0x20(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x161c0
leaq -0x50(%rbp), %rdi
callq 0x161c0
leaq -0x68(%rbp), %rdi
callq 0x161c0
leaq -0xb0(%rbp), %rdi
callq 0xb840
jmp 0xbd86
leaq -0x110(%rbp), %rdi
callq 0xb840
jmp 0xbd94
movsd -0x8(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movsd -0x18(%rbp), %xmm2
leaq -0x140(%rbp), %rdi
callq 0xbc40
jmp 0xbdb1
leaq -0x128(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0xc430
jmp 0xbdc6
leaq -0x38(%rbp), %rdi
movq %rdi, -0x390(%rbp)
leaq -0x128(%rbp), %rsi
movq %rsi, -0x398(%rbp)
callq 0x163b0
movq -0x398(%rbp), %rdi
callq 0x16350
leaq -0x140(%rbp), %rdi
callq 0x16350
movq -0x390(%rbp), %rdi
movl $0x1, %esi
callq 0x161a0
movq -0x390(%rbp), %rdi
movsd (%rax), %xmm0
movaps 0x101e1(%rip), %xmm1    # 0x1c000
pxor %xmm1, %xmm0
movsd %xmm0, -0x388(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x161a0
movsd -0x388(%rbp), %xmm0
movsd (%rax), %xmm1
leaq -0x158(%rbp), %rdi
xorps %xmm2, %xmm2
callq 0xbc40
jmp 0xbe51
leaq -0x50(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
leaq -0x158(%rbp), %rsi
movq %rsi, -0x3a8(%rbp)
callq 0x163b0
movq -0x3a8(%rbp), %rdi
callq 0x16350
movq -0x3a0(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x163e0
jmp 0xbe90
leaq -0x170(%rbp), %rdi
callq 0xc4f0
movsd %xmm0, -0x3b0(%rbp)
jmp 0xbea6
leaq -0x170(%rbp), %rdi
callq 0x16350
movsd -0x3b0(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xbf67
jp 0xbf67
leaq -0x188(%rbp), %rdi
movsd 0x10134(%rip), %xmm1    # 0x1c010
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0xbc40
jmp 0xbee9
leaq -0x50(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x163b0
leaq -0x188(%rbp), %rdi
callq 0x16350
jmp 0xbfdb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0xc3fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x16350
jmp 0xc3fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x16350
jmp 0xc3fa
leaq -0x1b8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x163e0
jmp 0xbf79
leaq -0x1a0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0xc430
jmp 0xbf8e
leaq -0x50(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x163b0
leaq -0x1a0(%rbp), %rdi
callq 0x16350
leaq -0x1b8(%rbp), %rdi
callq 0x16350
jmp 0xbfdb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x16350
jmp 0xc3fa
leaq -0x1e8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x163e0
jmp 0xbfed
leaq -0x200(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x163e0
jmp 0xbfff
leaq -0x1d0(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
leaq -0x200(%rbp), %rdx
callq 0xc570
jmp 0xc01b
leaq -0x68(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
movq %rsi, -0x3b8(%rbp)
callq 0x163b0
movq -0x3b8(%rbp), %rdi
callq 0x16350
leaq -0x200(%rbp), %rdi
callq 0x16350
leaq -0x1e8(%rbp), %rdi
callq 0x16350
leaq -0x260(%rbp), %rdi
movsd 0xffab(%rip), %xmm0     # 0x1c010
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq 0xbc40
jmp 0xc072
movsd -0x20(%rbp), %xmm0
callq 0xb610
movsd %xmm0, -0x3c0(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0xb0d0
movsd -0x3c0(%rbp), %xmm1
movaps %xmm0, %xmm2
movaps 0xff60(%rip), %xmm0     # 0x1c000
pxor %xmm0, %xmm2
leaq -0x278(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0xbc40
jmp 0xc0b5
movsd -0x20(%rbp), %xmm0
callq 0xb0d0
movsd %xmm0, -0x3c8(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0xb610
movsd -0x3c8(%rbp), %xmm1
movaps %xmm0, %xmm2
leaq -0x290(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0xbc40
jmp 0xc0ed
leaq -0x248(%rbp), %rdi
leaq -0x260(%rbp), %rsi
leaq -0x278(%rbp), %rdx
leaq -0x290(%rbp), %rcx
xorl %r8d, %r8d
callq 0xb930
jmp 0xc113
movq -0x208(%rbp), %rax
movq %rax, -0x70(%rbp)
movups -0x248(%rbp), %xmm0
movups -0x238(%rbp), %xmm1
movups -0x228(%rbp), %xmm2
movups -0x218(%rbp), %xmm3
movaps %xmm3, -0x80(%rbp)
movaps %xmm2, -0x90(%rbp)
movaps %xmm1, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x16350
leaq -0x278(%rbp), %rdi
callq 0x16350
leaq -0x260(%rbp), %rdi
callq 0x16350
leaq -0x2f0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x163e0
jmp 0xc189
leaq -0x308(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x163e0
jmp 0xc19b
leaq -0x320(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x163e0
jmp 0xc1ad
leaq -0x2d8(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
leaq -0x308(%rbp), %rdx
leaq -0x320(%rbp), %rcx
movl $0x1, %r8d
callq 0xb930
jmp 0xc1d6
movq -0x298(%rbp), %rax
movq %rax, -0xd0(%rbp)
movups -0x2d8(%rbp), %xmm0
movups -0x2c8(%rbp), %xmm1
movups -0x2b8(%rbp), %xmm2
movups -0x2a8(%rbp), %xmm3
movaps %xmm3, -0xe0(%rbp)
movaps %xmm2, -0xf0(%rbp)
movaps %xmm1, -0x100(%rbp)
movaps %xmm0, -0x110(%rbp)
leaq -0x320(%rbp), %rdi
callq 0x16350
leaq -0x308(%rbp), %rdi
callq 0x16350
leaq -0x2f0(%rbp), %rdi
callq 0x16350
movq -0x380(%rbp), %rdi
movq -0x70(%rbp), %rax
movq %rax, -0x330(%rbp)
movaps -0xb0(%rbp), %xmm0
movaps -0xa0(%rbp), %xmm1
movaps -0x90(%rbp), %xmm2
movaps -0x80(%rbp), %xmm3
movaps %xmm3, -0x340(%rbp)
movaps %xmm2, -0x350(%rbp)
movaps %xmm1, -0x360(%rbp)
movaps %xmm0, -0x370(%rbp)
movq -0x330(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x40(%rax)
movaps -0x370(%rbp), %xmm0
movaps -0x360(%rbp), %xmm1
movaps -0x350(%rbp), %xmm2
movaps -0x340(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x110(%rbp), %rsi
callq 0xbb60
jmp 0xc2ce
leaq -0x68(%rbp), %rdi
callq 0x16350
leaq -0x50(%rbp), %rdi
callq 0x16350
leaq -0x38(%rbp), %rdi
callq 0x16350
movq -0x378(%rbp), %rax
addq $0x410, %rsp            # imm = 0x410
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0xc32b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x16350
leaq -0x1e8(%rbp), %rdi
callq 0x16350
jmp 0xc3fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0xc38e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0xc382
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x16350
leaq -0x278(%rbp), %rdi
callq 0x16350
leaq -0x260(%rbp), %rdi
callq 0x16350
jmp 0xc3fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0xc3ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0xc3e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x320(%rbp), %rdi
callq 0x16350
leaq -0x308(%rbp), %rdi
callq 0x16350
leaq -0x2f0(%rbp), %rdi
callq 0x16350
leaq -0x68(%rbp), %rdi
callq 0x16350
leaq -0x50(%rbp), %rdi
callq 0x16350
leaq -0x38(%rbp), %rdi
callq 0x16350
movq -0xb8(%rbp), %rdi
callq 0xb5d0
nopw %cs:(%rax,%rax)