# Derive Rigid Transform Matrix from Axes and Origin [closed]

I'm trying to derive the matrix of a rigid transform to map between two coordinate spaces. I have the origin and the axis directions of the target coordinate space in terms of the known coordinate space; does anyone know how I can solve for the 4x4 rigid transformation matrix given these?

So, in other words, I have two coordinate spaces, A and B, and I know

Point3D originOfBInA;
Vector3D xAxisOfBInA; // Unit vector
Vector3D yAxisOfBInA; // Unit vector
Vector3D zAxisOfBInA; // Unit vector


And I'm trying to find the 4x4 matrix $\quad$

Matrix4x4 AtoB;


## closed as off-topic by José Carlos Santos, Lord Shark the Unknown, Xander Henderson, Adrian Keister, NamasteSep 18 '18 at 0:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – José Carlos Santos, Xander Henderson, Adrian Keister, Namaste
If this question can be reworded to fit the rules in the help center, please edit the question.

Let $e_1, e_2, e_3$ be a basis of coordinate space $A$. Express your given vectors (xAxisOfBInA, etc..) in terms of the basis of A, lets label them as column vectors $v_1, v_2, v_3$.

Then coordinate transform matrix is $C = \pmatrix{v_1 & |& v_2 &|& v_3}$. But since you are shifting the origin, you are doing a 3D affine transform, which can be represented as a 4D linear transform.

Represent coordinates $(x,y,z) \in A$ as $\vec{x} = (x,y,z,1)$. Then the representation of $\vec{x}$ in $B$ is $D\vec{x}$, where $D = \pmatrix{C & x_0 \\ 0 & 1}$, where $x_0$ is the representation of originOfBInA in terms of the basis of $A$.

If this is too abstract, I can work out an example if you'd like.

• Actually, hold on now, I'm not sure I follow. I understand the change of basis transform C , but the translation component of the affine transform I'm not sure I follow. If $x_0$ is the representation of the origin in B in terms of the basis of A, then $Dx_0 = \vec{0}$, or $Cx_0 + t = \vec{0}$, so $t = -Cx_0$. Doesn't this mean that $D = \pmatrix{C & -Cx_0 \\ 0 & 1}$? – anjruu Dec 6 '12 at 19:21
• Look at it this way. Let $\vec{X} = (x,y,z,1)$ and $\vec{x} = (x,y,z)$. Then, $D\vec{X} = C\vec{x} + x_0$ if you remove the extra $1$ coordinate after calculation is done. It looks like what you're saying is that $x_0$ is the origin of A and the zero vector is the origin of B. My statement is mapping the zero vector in A to the origin $x_0$ of B. Does that help at all? – countunique Dec 6 '12 at 20:03

I am sorry, I do not have enough reputation to add to your conversation. The correct transformation matrix in your case would indeed be:

$$D=\begin{bmatrix} C^{-1} & 0\\ 0 & 1 \end{bmatrix}\cdot\begin{bmatrix} 1 & -x_0\\ 0 & 1 \end{bmatrix}$$

The $$-x_0$$ part will translate the vector so that origins of both frames coincide, and the $$C^{-1}$$ part will represent coordinates of a vector in the new basis. The change of basis part is explained in great detail for example here: https://ltcconline.net/greenl/courses/203/Vectors/changeOfBasis.htm

And the translation part should be self-evident.

P. S. Sorry for answering this six years later, this thread popped up in my Google search on the first page, and the answer by countunique is clearly wrong.