{"id":180,"date":"2013-04-03T23:04:27","date_gmt":"2013-04-03T15:04:27","guid":{"rendered":"http:\/\/www.cgdev.net\/blog\/?p=180"},"modified":"2023-05-23T23:39:27","modified_gmt":"2023-05-23T15:39:27","slug":"gram-schmidt","status":"publish","type":"post","link":"https:\/\/www.cgdev.net\/blog\/180.html","title":{"rendered":"Gram-Schmidt Orthonormalization"},"content":{"rendered":"<p>We can use it to find an orthonormal basis for Tangent, Bitangent and Normal:<\/p>\n<p>\\begin{align}<br \/>\nT &amp;= T-\\frac{(T \\cdot N)N}{N \\cdot N} \\\\<br \/>\nB &amp;= B-\\frac{(B \\cdot N)N}{N \\cdot N}-\\frac{(B \\cdot T)T}{T \\cdot T}<br \/>\n\\end{align}<\/p>\n<p>If the input N and T are normalized already,\u00a0 then we can use the simplified code<\/p>\n<pre>T = (T - Dot(T, N) * N).Normalize();\r\nT = (Dot(Cross(N, T), B) &lt; 0) ? -T : T;\r\nB = (B - Dot(B, N) * N - Dot(B, T) * T).Normalize();\r\nB = (Dot(Cross(N, T), B) &lt; 0) ? -B : B;<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We can use it to find an orthonormal basis for Tangent, Bitangent and Normal: \\begin{align} T &amp;= T-\\frac{(T \\cdot N)N}{N \\cdot N} \\\\ B &amp;= B-\\frac{(B \\cdot N)N}{N \\cdot N}-\\frac{(B \\cdot T)T}{T \\cdot T} \\end{align} If the input N and T are normalized already,\u00a0 then we can use the simplified code T = (T &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,7],"tags":[4],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-graphics","category-math","tag-program"],"_links":{"self":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":0,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}