# Problem using superimposition_matrix from transformations.py in the tf package

I am trying to find the transformation matrix from one set of points to another, and tried to use the function "superimposition_matrix" (from transformations.py), but am getting unexpected results. I don't know if this is a bug or if I'm just missing something, but I was hoping someone could shed some light on my problem.

The function is defined/described as follows:

def superimposition_matrix(v0, v1, scaling=False, usesvd=True):
"Return matrix to transform given vector set into second vector set ..."


I've provided a simplified example below to illustrate my confusion. In this example, I am trying to find the transformation matrix from a unit-box centered at the origin, to a 100 side-length box with a corner at the origin. Having calculated the transformation matrix using the function superimposition_matrix(), I do a sanity check by transforming one of the corners of the unit-box, but do not get the expected result.

v0 = numpy.array(((0.5,-0.5,0),(0.5,0.5,0),(-0.5,0.5,0),(-0.5,-0.5,0)))
v1 = numpy.array(((100,0,0),(100,100,0),(0,100,0),(0,0,0)))
tfmatrix = superimposition_matrix(v0, v1, scaling=True, usesvd=True)
pos_orig = numpy.array((0.5,-0.5,0,1))
pos_new = numpy.dot(tfmatrix,pos_orig)
print(pos_new)


The array printed is "[ 48.24860074 -49.14653816 -17.21676633 1. ]" But I would expect the answer to be close to "[100 0 0 1.]"

• ROS version: Fuerte (Full-Desktop install)
• OS: Ubuntu 12.04 (Precise)
• Package: TF (Python)

Any insights would be appreciated. Thanks!

edit retag close merge delete

Sort by ยป oldest newest most voted

Your v0 and v1 are transposed. It will work as you expect if you run the code as above, but with tfmatrix = superimposition_matrix(v0.T, v1.T, scaling=True, usesvd=True)

Steve.

more