Search code examples
matrixhalcon

How to multiply Matrix with Vector in Halcon?


I am trying to multiply 4x4 transformation matrix with a Point Vector(4x1) in Halcon. Which command should i use since so far i haven't found anything

I tried to multiply with with hom_mat3d_compose and matrix_multiply but nothing so far.


Solution

  • Here are two methods. The first method uses homogenous coordinates. The second method can multiply any 4x4 matrix with a 4x1 matrix.

    *Method 1 - affine_trans_point_3d
    hom_mat3d_identity (HomMat3DIdentity)
    point_vector := [1, 2, 3, 1]
    affine_trans_point_3d (HomMat3DIdentity, point_vector[0], point_vector[1], 
    point_vector[2], Qx, Qy, Qz)
    
    *Method 2 - Matrix Multiplication
    matrix_identity := [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
    create_matrix (4, 4, matrix_identity, MatrixIdentity)
    matrix_point_vector := [1, 2, 3, 1]
    create_matrix (4, 1, matrix_point_vector, MatrixPointVector)
    mult_matrix (MatrixIdentity, MatrixPointVector, 'AB', MatrixMultID)