Why can i not create a rigid3d object from this matrix?
18 views (last 30 days)
Show older comments
Thomas Tramberger
on 13 Apr 2021
Answered: Pratyush Roy
on 18 May 2021
Hi,
i want to use Matlab for SfM. I have have position prior in world coordinates for the views that i read in from a csv file. When i want to create a rigid3d object from my data i get an error as seen in the following example copied from the command window:
posPrior =
1.000000000000000 -0.000113000000000 0.000234000000000 0
0.000114000000000 1.000000000000000 -0.000011000000000 0
-0.000234000000000 0.000011000000000 1.000000000000000 0
0.099970000000000 -0.299979000000000 0.885011000000000 1.000000000000000
Error using rigid3d (line 143)
The transformation matrix is not rigid.
A rigid transformation matrix must only contain a rotation and a translation.
The final column must consist of zeros, except for a one in the last row.
The posPrior matrix is my position i read in from my file. Then when i want to create a rigid3d object with pos = rigid3d(posPrior) i get the error. My matrix has the same structure as the T property so i dont know what im doing wrong here. I tried to separate the Rotation and Translation, but something seems wrong with the Rotation.
Thanks in advance
0 Comments
Accepted Answer
Pratyush Roy
on 18 May 2021
Hi Thomas,
For a transformation to be rigid, it should satisfy the following conditions:
1. Similarity Transform: For homogeneous scale, all singular values of the rotation matrix should approximately be equal (within roughly eps of largest singular value)
2. abs(det(T) - 1) ~= 0
The transformation matrix does not satisfy either of the above conditions. Both of these conditions fail due to small differences of about 1e-4.
'rigid3d' is working as expected. For the issue of using the same Transform matrix which worked before, there is a precision issue of what the older exported transformation was and what the new values you are trying to create rigid3d form. There could also possibly a datatype mismatch.
Using the same values as provided in the question, casting the values to single before creating the rigid3d object works fine. Please take a look at the following for single vs double values:
>>href = rigid3d(priorPos)
Error using rigid3d (line 143)
The transformation matrix is not rigid.
A rigid transformation matrix must only contain a rotation and a translation.
The final column must consist of zeros, except for a one in the last row.
Casting into single datatype resolves the issue. But note that doing this might lead in loss of precision.
>> href = rigid3d(single (priorPos))
href =
rigid3d with properties:
Rotation: [3x3 single]
Translation: [0.09997 -0.299979 0.885011]
Hope this helps!
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Object Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!