# How to find the $P_2$ when $T_1P_1=T_2P_2$

$T_1$ and $T_2$ are $3 \times 3$ homogenous transform matrices. $P_1$ is the $3 \times 1$ matrix with $x, y$ coordinates of point $P_1$.

What I am trying to do here is trying to get $x, y$ coordinate of point $P$ in coordinate system with transform $T_2$ when I know its $x, y$ in coordinate system with transform $T_1$.

Well in this relation it seems obvious that $P_2=T_2^{-1} \cdot T_1 \cdot P_1$. But this is giving wrong result in a code of mine. I am right now at my wit's end, so posted this question.

Are there any corner cases where this equation can fail? I know of one case when $\det(T_2)=0$.

-
What exactly are the $T_i$ and the $P_i$ that are giving you trouble? What results are you getting, and what results do you think you should see? – J. M. Aug 29 '11 at 14:31
same question as above. Are the matrices represented in a symbolic way or numerical? – newbie Aug 29 '11 at 14:34
@J.M. For any values of $T_i$ and $P_i$ it gives me trouble. The value of $P_2$ I get is quite far off. I am not sure what's going on but I rechecked the program a number of times and the logic seems to be fine. From your response it seems there aren't any more corner cases. Then I guess I need to revisit my code again. – AppleGrew Aug 29 '11 at 15:11
@newbie I really didn't get your question. – AppleGrew Aug 29 '11 at 15:13
"any"? Something indeed is off. You keep saying "far off"but you didn't say exactly what you're seeing and what you think you should be seeing... – J. M. Aug 29 '11 at 15:15

Don't take this answer as an answer. I'm writing here simply because it is easier to edit. Here we go.

Say $\tilde{x}$ is a vector lying in $\mathbb{R}^3$ space(your Euclidean space).

If you only have one transform variable, it only allows you to transfrom in $\mathbb{R}^2$ (sub)space. In order to transform in 3D, you need two angle variables.

Check wiki for the details. In the course of one rotation, you have to rotation about ONE axis, whose coordinate would remain unchanged.

If it is a rotation matrix, in convention it means you rotation the vector COUNTERCLOCKWISELY (wiki is sometimes confusing :D) by angle $\theta$, while the matrix is $$\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}$$

so, if $$T_{1}(\alpha) = \begin{bmatrix} \cos\alpha & -\sin\alpha \\ \sin\alpha & \cos\alpha \end{bmatrix}$$

$$T_{2}(\gamma) = \begin{bmatrix} \cos\gamma & -\sin\gamma \\ \sin\gamma & \cos\gamma \end{bmatrix}$$,

then $T_{2}^{-1}T_{1}\vec{x}$ means rotating $\vec{x}$ counterclockwisely by $\alpha$ then clockwisely by $\gamma$. So actually you can use $$T_{2}^{-1}T_{1}\vec{x} = \tilde{T} = \begin{bmatrix} \cos(\alpha-\gamma) & -\sin(\alpha-\gamma) \\ \sin(\alpha-\gamma) & \cos(\alpha-\gamma) \end{bmatrix}$$

Though it is equivalent in mathematics, it simplifies the computation a little bit and it also avoids inverse and matrix multiplication.

I only work in 2D because if the thrid dimension remains the same: if $$T_{2}(\gamma) = \begin{bmatrix} \cos\gamma & -\sin\gamma & 0 \\ \sin\gamma & \cos\gamma & 0 \\ 0&0&1 \end{bmatrix}$$ the third entry of vector $\vec{x}$ wouldn't be changed. So actually you can reduce the dimension.

I hope it helps a bit. And using uppercase only means to grasp some attention and doesn't mean to offend anyone.

-
I have solved my issue. :) I am still not sure why, but If I to use $T_2*T_1^{-1}$ instead, then it works! My matrices handle only 2D case, not 3D. In my case the transform, may contain translation, scaling, skew too along with rotation. – AppleGrew Aug 30 '11 at 11:10
that's good. But you do know that a hybrid(containing translation, scaling,tec) can be decomposed into separate matrices (which operate as simple translation, scaling, etc). May I ask if you are working on an issure relevant to continuum mechanics? if so, you should look into polar decomposition. It shows your transform can be always decomposed into skewing, rotation and translation. good luck with the rest. – newbie Aug 30 '11 at 11:42
@Apple: I'm guessing your system uses row vectors instead of column vectors? – J. M. Aug 30 '11 at 12:42
@newbie I am using these matrices to draw stuffs on HTML canvas. – AppleGrew Aug 30 '11 at 13:52
@J.M. I am working with scalars. $P_i$ is just the xy of the point, no direction sense in that. I in fact have a working code in Javascript which does exactly the thing I want, in exactly the way I expect it to. Unfortunately, the actual code where I wanted it to work is way too complicated. If I think trough that then maybe I might understand what is different there. Anyway, whatever works! :) – AppleGrew Aug 30 '11 at 13:57