"Pinpress" <nospam__@yahoo.com> wrote in message <gkkqeh$idk$1@fred.mathworks.com>...
> Hi all,
>
> I wonder if there is an existing program that solves the matrix equation: TA = BT, in which T is to be solved, all matrices (T, A, B) are 4by4 matrices. In addition, it is prior information that all matrices are rigidbody transformation matrices, so T only has 12 unknowns.
>
> Please also note that I have many equations similar to the one given, so:
>
> T*A1 = B1*T;
> T*A2 = B2*T;
> ...
> T*An = Bn*T;
>
> In all of the equations, T should be the same. So my question is, how to solve T? thanks for any input.
Pinpress, you haven't told us if there is anything special about A and B. For example, if they, along with T, represent affine threedimensional transformations in terms of augmented matrices, they would all have [0,0,0,1] in their bottom rows. The upper left 3x3 part would be a linear transformation and the rightmost top 3x1 part a subsequent translation. The transformation would be achieved by multiplying a column vector [x;y;z;1] on its left by the matrix as explained in:
http://en.wikipedia.org/wiki/Affine_transformation
You would then be taking the difference between 1) an affine transformation A followed by a rotation/translation T, and 2) the rotation/translation T followed by another affine transformation B, and hoping to find a T that would make that difference identically zero. Moreover this should be done for the same T and many different pairs of A and B.
As you will see, it is a rather stringent condition that A and B are such that a solution T exists. Consider just the upper left 3x3 part in A, B, and T, and call them a, b, and t, respectively. By the nature of such matrices we must have t*a = b*t. Then take the singular value decomposition of a and b
[ua,sa,va] = svd(a)
[ub,sb,vb] = svd(b)
where a = ua*sa*va and b = ub*sb*vb. Such singular value decompositions into a unitary matrix times a nonnegative diagonal matrix times another unitary matrix are unique (assuming the three singular values are unequal.) Since we have t*a = b*t, we must have the equality
(t*ua)*(sa)*(va) = (ub)*(sb)*(vb*t).
Here, t being a rotation matrix and therefore a valid unitary matrix, the products t*ua and vb*t are in themselves valid unitary matrices and it follows from the above uniqueness that
t*ua = ub
sa = sb
va = vb*t
This shows that we can compute t as t = ub*ua' or t = vb'*va whichever we please. It also shows that the a and b svd decompositions must satisfy the equality
va*ua = vb*ub
and that a and b must have the same singular values in sa and sb. As I say, A and B must satisfy a very strong condition for any T to possibly exist.
I leave it to you to work out the details of the problem for the remaining translational aspects of these matrices  that is, the upper right 3x1 portion of the matrices.
Roger Stafford
