ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Wed, 30 Apr 2014 13:18:29 -0500Problem using superimposition_matrix from transformations.py in the tf packagehttps://answers.ros.org/question/55085/problem-using-superimposition_matrix-from-transformationspy-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!Tue, 12 Feb 2013 17:34:55 -0600https://answers.ros.org/question/55085/problem-using-superimposition_matrix-from-transformationspy-in-the-tf-package/Answer by ssafarik for <p>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.</p>
<p>The function is defined/described as follows:</p>
<pre><code>def superimposition_matrix(v0, v1, scaling=False, usesvd=True):
"Return matrix to transform given vector set into second vector set ..."
</code></pre>
<p>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.</p>
<pre><code>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)
</code></pre>
<p>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.]"</p>
<ul>
<li>ROS version: Fuerte (Full-Desktop install)</li>
<li>OS: Ubuntu 12.04 (Precise)</li>
<li>Package: TF (Python)</li>
</ul>
<p>Any insights would be appreciated. Thanks!</p>
https://answers.ros.org/question/55085/problem-using-superimposition_matrix-from-transformationspy-in-the-tf-package/?answer=159316#post-id-159316Your 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.
Wed, 30 Apr 2014 13:18:29 -0500https://answers.ros.org/question/55085/problem-using-superimposition_matrix-from-transformationspy-in-the-tf-package/?answer=159316#post-id-159316