# Calculate Transformation between two point sets - but with constrained Degrees of Freedom

How can I calculate the rigid-body transformation [R|t] between two 3d triangles, but restricted to a given N degrees of freedom (for N = 1..6) ?

I know for N=6 I can get a least-squares solution via SVD of a certain matrix, but how can I integrate further constraints (fewer DOF) into the system?

Regardless of the number and kind of degrees of freedom you are using this is a least squares optimization problem. A basic approach is:

1. write the transformation matrices that you are planning to use as a parameterized function

2. use an initial guess to get the results for the triangle coordinates and calculte the obtained coordinates using the initial guess paramters

3. calculate the distance from the obtained points in step 2 to the required points
4. iterate and refine the intial guess using an optimisation method (e.g. a simple gradient descent) until you reac a certein desired precision

The above algorithm is similar (maybe more simplistic) to the Iterative Closes Point algorithm, used for SLAM.