1
$\begingroup$

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; 

2 Answers 2

1

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.

  • 0
    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?2012-12-06
0

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.