<p>I was trying to follow this <a href="http://foundationsofgameenginedev.com/FGED2-sample.pdf" rel="nofollow noreferrer">http://foundationsofgameenginedev.com/FGED2-sample.pdf</a></p>
<p>But had problem understanding formula 7.33.
<span class="math-container">$$p_i-p_j=(u_i-u_j)\mathrm{t}+(v_i-v_j)\mathrm{b}$$</span>
* <span class="math-container">$p_i,p_j$</span> being vertices on a triangle, and <span class="math-container">$u_*,v_*$</span> being their texture coordiniates, and <span class="math-container">$M_{tangent}=\left[\mathrm{t}\space\mathrm{b}\space\mathrm{n}\right]$</span></p>
<p>If the matrix has to be orthogonal (why though?), then if I'm not mistaken, all its vectors have to measure 1 in magnitude. It surely looks like there lacks constraints on <span class="math-container">$p_i$</span> and <span class="math-container">$p_j$</span> - they can be at any distance from each other while <span class="math-container">$\left|u_i-u_j\right|&lt;1$</span>.</p>
<p>Where did I get it wrong?</p>
<hr />
<p>@pmw1234
Please read the following and do elaborate a little.
I'm all confused here. Whether or not the textbooks I have are good enough.</p>
<p>The book says because <strong>M</strong> is orthogonal, <span class="math-container">$M^T$</span> is the reverse transformation.</p>
<p>The textbook definition of an orthogonal matrix is <span class="math-container">$$\begin{equation}{M^T}{M}={M}{M^T}=I\end{equation}$$</span> or <span class="math-container">$${M^T}={M^{-1}}$$</span></p>
<p>From the definition follows one of the properties:</p>
<p>A matrix is orthogonal if and only if its rows/cols are orthonormal vectors.</p>
<p>Proof:</p>
<p><span class="math-container">$$
\begin{eqnarray}
\text{Because}\\
M&amp;=&amp;\begin{bmatrix}
\mathrm{r}_{1}\\
\mathrm{r}_{2}\\
\vdots\\
\mathrm{r}_{n}
\end{bmatrix}\\
M^T&amp;=&amp;\begin{bmatrix}\mathrm{r}_{1}^T&amp;\mathrm{r}_{2}^T&amp;\ldots&amp;\mathrm{r}_{n}^T\end{bmatrix}\\
M\times{M^T}&amp;=&amp;\begin{bmatrix}
\mathrm{r}_{1}\mathrm{r}_{1}^T&amp;\mathrm{r}_{1}\mathrm{r}_{2}^T&amp;\ldots&amp;\mathrm{r}_{1}\mathrm{r}_{n}^T\\
\mathrm{r}_{2}\mathrm{r}_{1}^T&amp;\mathrm{r}_{2}\mathrm{r}_{2}^T&amp;\ldots&amp;\mathrm{r}_{2}\mathrm{r}_{n}^T\\
\vdots&amp;\vdots&amp;\ddots&amp;\vdots\\
\mathrm{r}_{n}\mathrm{r}_{1}^T&amp;\mathrm{r}_{n}\mathrm{r}_{2}^T&amp;\ldots&amp;\mathrm{r}_{n}\mathrm{r}_{n}^T
\end{bmatrix}\\
\\
\text{Therefore}\\
\mathrm{r}_{i}\mathrm{r}_{j}^T&amp;=&amp;0&amp;(i\neq{j})\\
\mathrm{r}_{i}\mathrm{r}_{i}^T&amp;=&amp;\left|\mathrm{r}_{i}\right|=1\\
\\
\end{eqnarray}
$$</span></p>
<p>i.e. the rows form an orthonormal basis.</p>
<p>Q.E.D.</p>
<p>If the book calling <strong>M</strong> orthogonal isn't enough, and the rows are merely literally &quot;orthogonal&quot; to each other, I don't see how the &quot;reverse transformation&quot; is meaningful.</p>
<p>A trivial example is.</p>
<p><span class="math-container">$$
\begin{eqnarray}
M&amp;=&amp;\begin{bmatrix}
2&amp;0&amp;0\\
0&amp;1&amp;0\\
0&amp;0&amp;1\\
\end{bmatrix}\textrm{the rows being perfectly "orthogonal"}\\
M^T&amp;=&amp;M\\
V&amp;=&amp;\begin{bmatrix}
1\\
1\\
1\\
\end{bmatrix}\\
M\times{V}&amp;=&amp;\begin{bmatrix}
2\\
1\\
1\\
\end{bmatrix}\\
M^T\times{M}\times{V}&amp;=&amp;\begin{bmatrix}
4\\
1\\
1\\
\end{bmatrix}
\end{eqnarray}
$$</span>
I can't see how <span class="math-container">$M^T$</span> reverses anything.</p>

CC BY-SA 4.0
2020-12-22T00:23:29.077Z
This is more of a linear algebra question. But if you really stop and think about it, two vectors can still be orthogonal and have very different magnitudes. Just image a short vector (small magnitude) orthogonal to a very long vector (high magnitude). Since vectors don't have position, it doesn't matter where the original points are. The end goal being to generate an orthonormal basis (which is orthogonal by definition) that allows us to perform a "change of basis" on both vertices and vectors, in this case from object space to so call "tangent space".
pmw1234
CC BY-SA 4.0
2020-12-22T02:14:10.357Z
I understand two vectors can be orthogonal no matter their magnitudes, but the text says the very Matrix is orthogonal and even gives its transpose as its inverse. I read the given code, if I understand correctly, it generates an "average" tangent by summing up all tangents and normalizing the result, then produces an orthonormal basis of [t, b, n]. But 7.33 to me, definitely won't guarantee orthonormal t and b.
Eugene
CC BY-SA 4.0
2020-12-22T02:20:42.693Z
@pmw1234 So it's summing up tangents of various magnitudes (each derived from 7.33) to generate the "average". I can't figure out the math behind this.
Eugene
CC BY-SA 4.0
2020-12-22T21:02:51.760Z
That equation is saying: Given the vector Pij that you can move in the U direction some number of units and then in the V direction some number of units, and the sum of those two vectors is the same is Pij. U and V are coordinate axis in the basis that we are looking for and they are called the tangent and bitangent. Together with the normal we have a complete TBN basis. Later they have to be normalized (which the text even points out) in order to make the final basis using the gram schmidt process.
pmw1234
CC BY-SA 4.0
2021-01-12T01:51:58.147Z
@pmw1234 Sorry for the slow reply, I see that they are normalized later. I was assuming this formula should give me unit t and b, since it follows the part stating that the matrix is orthogonal, and is using the same letters. Small modifications say, with t', b', would clear things up for me. And finally thanks for your kind replies.
Eugene
CC BY-SA 4.0
2021-01-13T16:56:43.957Z
It is perfectly plausible to have an orthogonal matrix which does not have unit vectors. The length of the vectors act as a scaling value, but don't change the vector direction. This is why we can get away with summing all the vectors at each vertex. The vertex directions tend to "average" each other out, while the length of the vectors only contribute to the scale. So when its all said and done we can just throw away the scaling factor and keep the direction. BTW happy to help out, explaining helps me understand it better too.
pmw1234
CC BY-SA 4.0
2021-01-14T02:21:44.530Z
@pmw1234 That's unless the book isn't using the term in its textbook definition, but it likely does, since as I've mentioned, it says the transpose is the "reverse transformation", by which if it means M_transpose == M_inverse, the rows and columns of M have to be orthonormal. Or if M_transpose != M_inverse, the "reverse transformation" is pointless, since M_transpose may neither restore the direction nor the magnitude.
Eugene
CC BY-SA 4.0
2021-01-14T11:56:16.197Z
I recommend you get a good book on linear algebra like the first book in the foundation series as it explains many of the areas you are finding confusing. Such as why the transpose is equal to the inverse in certain cases, and what the "reverse transformation" is.
pmw1234
CC BY-SA 4.0
2021-01-16T01:30:40.827Z
@pmw1234 I do have a few. In fact I can prove how M's tranpose must = M's inverse if and only if M's rows/cols are orthonormal. If I got anything wrong, could you just point it out? As for reverse transformation, say M = [[2,0,0], [0,1,0], [0,0,1]], perfectly orthogonal by your standard. It's transpose is itself, which however can't reverse what M has transformed, say [1,1,1].
Eugene
CC BY-SA 4.0
2021-01-16T03:06:10.657Z
@pmw1234 I just added my reasoning in the question for better formatting.
Eugene
CC BY-SA 4.0
2021-01-20T14:58:56.237Z
Right, so now you have 3 vectors that are orthogonal, but you aren't done creating your basis so you can't transpose it and expect a valid result. First you must remove the magnitude on each vector, then you can do the transpose. Your example is skipping the "remove the magnitude" step. And that is what equations 7.38,7.39 are doing. The basis isn't formed until both those equations have been applied. Once that is done, equations 7.31 and 7.32 become valid and your completed T,B,N vectors now form a valid basis.
pmw1234
<transformations><shading><normal-mapping>
Help me understand the derivation of this tangent space to object space matrix
Eugene
# Help me understand the derivation of this tangent space to object space matrix

(Asked by: username_0 on 2020-12-18)

I was trying to follow this <http://foundationsofgameenginedev.com/FGED2-sample.pdf>

But had problem understanding formula 7.33.
$$p\_i-p\_j=(u\_i-u\_j)\mathrm{t}+(v\_i-v\_j)\mathrm{b}$$
\* $p\_i,p\_j$ being vertices on a triangle, and $u\_\*,v\_\*$ being their texture coordiniates, and $M\_{tangent}=\left[\mathrm{t}\space\mathrm{b}\space\mathrm{n}\right]$

If the matrix has to be orthogonal (why though?), then if I'm not mistaken, all its vectors have to measure 1 in magnitude. It surely looks like there lacks constraints on $p\_i$ and $p\_j$ - they can be at any distance from each other while $\left|u\_i-u\_j\right|<1$.

Where did I get it wrong?

---

@username_1
Please read the following and do elaborate a little.
I'm all confused here. Whether or not the textbooks I have are good enough.

The book says because **M** is orthogonal, $M^T$ is the reverse transformation.

The textbook definition of an orthogonal matrix is $$\begin{equation}{M^T}{M}={M}{M^T}=I\end{equation}$$ or $${M^T}={M^{-1}}$$

From the definition follows one of the properties:

A matrix is orthogonal if and only if its rows/cols are orthonormal vectors.

Proof:

$$
\begin{eqnarray}
\text{Because}\\
M&=&\begin{bmatrix}
\mathrm{r}\_{1}\\
\mathrm{r}\_{2}\\
\vdots\\
\mathrm{r}\_{n}
\end{bmatrix}\\
M^T&=&\begin{bmatrix}\mathrm{r}\_{1}^T&\mathrm{r}\_{2}^T&\ldots&\mathrm{r}\_{n}^T\end{bmatrix}\\
M\times{M^T}&=&\begin{bmatrix}
\mathrm{r}\_{1}\mathrm{r}\_{1}^T&\mathrm{r}\_{1}\mathrm{r}\_{2}^T&\ldots&\mathrm{r}\_{1}\mathrm{r}\_{n}^T\\
\mathrm{r}\_{2}\mathrm{r}\_{1}^T&\mathrm{r}\_{2}\mathrm{r}\_{2}^T&\ldots&\mathrm{r}\_{2}\mathrm{r}\_{n}^T\\
\vdots&\vdots&\ddots&\vdots\\
\mathrm{r}\_{n}\mathrm{r}\_{1}^T&\mathrm{r}\_{n}\mathrm{r}\_{2}^T&\ldots&\mathrm{r}\_{n}\mathrm{r}\_{n}^T
\end{bmatrix}\\
\\
\text{Therefore}\\
\mathrm{r}\_{i}\mathrm{r}\_{j}^T&=&0&(i\neq{j})\\
\mathrm{r}\_{i}\mathrm{r}\_{i}^T&=&\left|\mathrm{r}\_{i}\right|=1\\
\\
\end{eqnarray}
$$

i.e. the rows form an orthonormal basis.

Q.E.D.

If the book calling **M** orthogonal isn't enough, and the rows are merely literally "orthogonal" to each other, I don't see how the "reverse transformation" is meaningful.

A trivial example is.

$$
\begin{eqnarray}
M&=&\begin{bmatrix}
2&0&0\\
0&1&0\\
0&0&1\\
\end{bmatrix}\textrm{the rows being perfectly "orthogonal"}\\
M^T&=&M\\
V&=&\begin{bmatrix}
1\\
1\\
1\\
\end{bmatrix}\\
M\times{V}&=&\begin{bmatrix}
2\\
1\\
1\\
\end{bmatrix}\\
M^T\times{M}\times{V}&=&\begin{bmatrix}
4\\
1\\
1\\
\end{bmatrix}
\end{eqnarray}
$$
I can't see how $M^T$ reverses anything.

**Tags:** transformations, shading, normal-mapping

> **Comments:**
> **username_1**: This is more of a linear algebra question. But if you really stop and think about it, two vectors can still be orthogonal and have very different magnitudes. Just image a short vector (small magnitude) orthogonal to a very long vector (high magnitude). Since vectors don't have position, it doesn't matter where the original points are. The end goal being to generate an orthonormal basis (which is orthogonal by definition) that allows us to perform a "change of basis" on both vertices and vectors, in this case from object space to so call "tangent space".  
> **username_0**: I understand two vectors can be orthogonal no matter their magnitudes, but the text says the very Matrix is orthogonal and even gives its transpose as its inverse. I read the given code, if I understand correctly, it generates an "average" tangent by summing up all tangents and normalizing the result, then produces an orthonormal basis of [t, b, n]. But 7.33 to me, definitely won't guarantee orthonormal t and b.  
> **username_0**: @username_1 So it's summing up tangents of various magnitudes (each derived from 7.33) to generate the "average". I can't figure out the math behind this.  
> **username_1**: That equation is saying: Given the vector Pij that you can move in the U direction some number of units and then in the V direction some number of units, and the sum of those two vectors is the same is Pij. U and V are coordinate axis in the basis that we are looking for and they are called the tangent and bitangent. Together with the normal we have a complete TBN basis. Later they have to be normalized (which the text even points out) in order to make the final basis using the gram schmidt process.  
> **username_0**: @username_1 Sorry for the slow reply, I see that they are normalized later. I was assuming this formula should give me unit t and b, since it follows the part stating that the matrix is orthogonal, and is using the same letters. Small modifications say, with t', b', would clear things up for me. And finally thanks for your kind replies.  
> **username_1**: It is perfectly plausible to have an orthogonal matrix which does not have unit vectors. The length of the vectors act as a scaling value, but don't change the vector direction. This is why we can get away with summing all the vectors at each vertex. The vertex directions tend to "average" each other out, while the length of the vectors only contribute to the scale. So when its all said and done we can just throw away the scaling factor and keep the direction. BTW happy to help out, explaining helps me understand it better too.  
> **username_0**: @username_1 That's unless the book isn't using the term in its textbook definition, but it likely does, since as I've mentioned, it says the transpose is the "reverse transformation", by which if it means M_transpose == M_inverse, the rows and columns of M have to be orthonormal. Or if M_transpose != M_inverse, the "reverse transformation" is pointless, since M_transpose may neither restore the direction nor the magnitude.  
> **username_1**: I recommend you get a good book on linear algebra like the first book in the foundation series as it explains many of the areas you are finding confusing. Such as why the transpose is equal to the inverse in certain cases, and what the "reverse transformation" is.  
> **username_0**: @username_1 I do have a few. In fact I can prove how M's tranpose must = M's inverse if and only if M's rows/cols are orthonormal. If I got anything wrong, could you just point it out? As for reverse transformation, say M = [[2,0,0], [0,1,0], [0,0,1]], perfectly orthogonal by your standard. It's transpose is itself, which however can't reverse what M has transformed, say [1,1,1].  
> **username_0**: @username_1 I just added my reasoning in the question for better formatting.  
> **username_1**: Right, so now you have 3 vectors that are orthogonal, but you aren't done creating your basis so you can't transpose it and expect a valid result. First you must remove the magnitude on each vector, then you can do the transpose. Your example is skipping the "remove the magnitude" step. And that is what equations 7.38,7.39 are doing. The basis isn't formed until both those equations have been applied. Once that is done, equations 7.31 and 7.32 become valid and your completed T,B,N vectors now form a valid basis.  

---

## 0 answers

