Ask Your Question

Problem using superimposition_matrix from in the tf package

asked 2013-02-12 17:34:55 -0600

davidcw gravatar image

updated 2014-01-28 17:15:13 -0600

ngrennan gravatar image

I am trying to find the transformation matrix from one set of points to another, and tried to use the function "superimposition_matrix" (from, 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 =,pos_orig)

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-04-30 13:18:29 -0600

ssafarik gravatar image

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)


edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-02-12 17:34:55 -0600

Seen: 300 times

Last updated: Apr 30 '14