<p>I have two meshes that I want to align, I'll call the reference mesh the <em>template mesh</em> and the other is the <em>target mesh</em>. I have 1 point-to-point correspondence between my template and target mesh. 
I am trying to find the uniform scale and translation to align these 2 meshes. 
This is what I've been doing :</p>

<p>My optimal transformation matrix M = <code>[M11 0 0 M14; 0 M11 0 M24 ; 0 0 M11 M34; 0 0 0 1 ]</code> , here M11 is my scale and M14, M24, M34 are the translation in x,y and z.
I represent my points from the template mesh as homogeneous coordinates -> A = <code>[xt, yt, zt, 1]</code>
the corresponding points on the target mesh -> B = <code>[xp, yp, zp, 1]</code></p>

<p>I know that :</p>

<pre><code>xp = M11*xt + M14
yp = M11*xt + M24
zp = M11*xt + M34
</code></pre>

<p>This is how I form and solve my least sqauares problem :</p>

<pre><code>findMin((X*T - B)^2) 
</code></pre>

<p>Where T, X and B are  :</p>

<pre><code>  B  =      X      *   T
  [xp  [ xt 1 0 0    [M11
   yp =  yt 0 1 0  *  M14
   zp    zt 0 0 1     M24
   1]    1  1 1 1]    M34]
</code></pre>

<p>This is how I find the least squares fit for T :</p>

<pre><code>(Inverse(X'*X))*X'*B
</code></pre>

<p>I am not sure if this is the right way to go about this, particularly</p>

<ol>
<li>Is it acceptable to add the row of ones in the last row of matrix X
in my least sqaures problem? It has no physical meaning, I just
added it to make dimensions match and ensure that the matrix X is
invertible.</li>
<li>With this I get negative scale values, is there a way I can add constraints in the least squares problem to ensure that I get a scale that is always greater than 0? Is this even the right approach to find a scale value?</li>
</ol>

CC BY-SA 4.0
2019-11-16T14:47:46.087Z
Probably better to add 0 and only have on 1 on the row.
joojaa
CC BY-SA 4.0
2019-11-16T16:19:07.693Z
Also note that the  multiplication makes the matrix square.
joojaa
CC BY-SA 4.0
2019-11-17T05:13:55.577Z
@Rahul , I am not sure if I can drop the last entry of B and X, since my T matrix is still a 4X1 matrix.  My first doubt is, does it even make sense to estimate scale and translation from just 1 point to point correspondence between 2 objects? Ordinary Procrustes analysis seems promising, and I am actually trying to implement a skeleton fitting algorithm. I'll try that method and get back with the results.
Mn9
CC BY-SA 4.0
2019-11-17T10:39:48.630Z
yes, that makes sense to me. I got this question while reading this paper - https://www.cs.utah.edu/~ladislav/saito15computational/saito15computational.pdf. In section 3.4, they say they estimate uniform scale and translation for both ends of the bone, with just one point-to-point correspondence at each end. I was wondering if this was done using a least squares optimiser? Thanks for all the help!
Mn9
<optimisation>
Least squares for uniform scale and translation
Mn9
# Least squares for uniform scale and translation

(Asked by: username_0 on 2019-11-16)

I have two meshes that I want to align, I'll call the reference mesh the *template mesh* and the other is the *target mesh*. I have 1 point-to-point correspondence between my template and target mesh.
I am trying to find the uniform scale and translation to align these 2 meshes.
This is what I've been doing :

My optimal transformation matrix M = `[M11 0 0 M14; 0 M11 0 M24 ; 0 0 M11 M34; 0 0 0 1 ]` , here M11 is my scale and M14, M24, M34 are the translation in x,y and z.
I represent my points from the template mesh as homogeneous coordinates -> A = `[xt, yt, zt, 1]`
the corresponding points on the target mesh -> B = `[xp, yp, zp, 1]`

I know that :

```
xp = M11*xt + M14
yp = M11*xt + M24
zp = M11*xt + M34

```

This is how I form and solve my least sqauares problem :

```
findMin((X*T - B)^2) 

```

Where T, X and B are :

```
  B  =      X      *   T
  [xp  [ xt 1 0 0    [M11
   yp =  yt 0 1 0  *  M14
   zp    zt 0 0 1     M24
   1]    1  1 1 1]    M34]

```

This is how I find the least squares fit for T :

```
(Inverse(X'*X))*X'*B

```

I am not sure if this is the right way to go about this, particularly

1. Is it acceptable to add the row of ones in the last row of matrix X
   in my least sqaures problem? It has no physical meaning, I just
   added it to make dimensions match and ensure that the matrix X is
   invertible.
2. With this I get negative scale values, is there a way I can add constraints in the least squares problem to ensure that I get a scale that is always greater than 0? Is this even the right approach to find a scale value?

**Tags:** optimisation

> **Comments:**
> **username_1**: Probably better to add 0 and only have on 1 on the row.  
> **username_1**: Also note that the  multiplication makes the matrix square.  
> **username_0**: @Rahul , I am not sure if I can drop the last entry of B and X, since my T matrix is still a 4X1 matrix.  My first doubt is, does it even make sense to estimate scale and translation from just 1 point to point correspondence between 2 objects? Ordinary Procrustes analysis seems promising, and I am actually trying to implement a skeleton fitting algorithm. I'll try that method and get back with the results.  
> **username_0**: yes, that makes sense to me. I got this question while reading this paper - https://www.cs.utah.edu/~ladislav/saito15computational/saito15computational.pdf. In section 3.4, they say they estimate uniform scale and translation for both ends of the bone, with just one point-to-point correspondence at each end. I was wondering if this was done using a least squares optimiser? Thanks for all the help!  

---

## 0 answers

