Getting column of a 4x4 matrix

Hi everyone,

I’m trying to get the z axis from matrix 4x4 matrix using the getCol3 method of the class but it doesn’t seem to give me what I want :rofl:

Here’s a test:

    from panda3d.core import Mat4
    mat = Mat4(0.98511, -0.0449334, -0.165952, 0, -0.0449334, 0.864408, -0.500779, 0, 0.165952, 0.500779, 0.849518, 0, 0, 0, 0, 1)
    print('Mat')
    print(mat)
    for i in range(3):
        print('Col {}'.format(i))
        print(mat.getCol3(i))
Mat
0.98511 -0.0449334 -0.165952 0
-0.0449334 0.864408 -0.500779 0
0.165952 0.500779 0.849518 0
0 0 0 1
Col 0
LVecBase3f(0.98511, -0.0449334, -0.165952)
Col 1
LVecBase3f(-0.0449334, -0.165952, 0)
Col 2
LVecBase3f(-0.165952, 0, -0.0449334)

I’m not sure why getCol3 seems to be failing for you. What version of Panda3D do you have? Which operating system? Is your version of Panda3D built with Eigen support enabled?

Does mat.cols[i].xyz produce the desired result?

I can actually reproduce this issue on a build with Eigen enabled, and it happens on the getCol3 and getRow3 methods. I have committed a bug fix for the upcoming 1.10.3 release. I suggest you just use .cols[i].xyz instead for now.

It works great :stuck_out_tongue_winking_eye:
Cheers all!