Skip to content

Getting different results from two identical matrices #1

@n8xm

Description

@n8xm

If I run the following code:

from sophus import SE3
import numpy as np
import math

angle = math.pi/4;
T1 = SE3.rotX(angle)
T1_numpy = T1.matrix();
T2_numpy = np.array([[1, 0, 0, 0],
                     [0, math.cos(angle), -math.sin(angle), 0],
                     [0, math.sin(angle), math.cos(angle), 0],
                     [0, 0, 0, 1]])

print(np.allclose(T1_numpy,T2_numpy)) #result is "true"
print(SE3(T1_numpy))
print(SE3(T2_numpy))

It is evident that T1_numpy and T2_numpy contain the same values up to some (very small) epsilon, because print(np.allclose(T1_numpy,T2_numpy)) returns true.

However, print(SE3(T1_numpy)) gives me the following output:

[[ 1.          0.          0.          0.        ]
 [ 0.          0.70710678 -0.70710678  0.        ]
 [ 0.          0.70710678  0.70710678  0.        ]
 [ 0.          0.          0.          1.        ]]

Whereas print(SE3(T2_numpy)) gives me this:

[[ 1.         -0.          0.          0.        ]
 [ 0.          0.70710678  0.70710678  0.        ]
 [-0.         -0.70710678  0.70710678  0.        ]
 [ 0.          0.          0.          1.        ]]

The two results should be the same! Instead, one is the inverse of the other! What is going on here? Is this a bug? Or have I missed something really obvious?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions