{"id":252,"date":"2018-05-22T20:11:49","date_gmt":"2018-05-22T18:11:49","guid":{"rendered":"http:\/\/mouca.fr\/wordpress\/?p=252"},"modified":"2018-10-15T08:45:23","modified_gmt":"2018-10-15T06:45:23","slug":"matrix-quaternion-and-scene-graph-part1","status":"publish","type":"post","link":"http:\/\/mouca.fr\/wordpress\/en\/2018\/05\/22\/matrix-quaternion-and-scene-graph-part1\/","title":{"rendered":"Matrix, quaternion and scene graph: Part1"},"content":{"rendered":"<p>Hi everyone, today I want to speak about math, simply if possible, because the topic is about matrix &amp; quaternion.<\/p>\n<p>The main goal of this series of posts is to use them correctly inside an applied case: the scene graph and how to compute modelview-projection.<\/p>\n<h1>Preface<\/h1>\n<div class=\"alert alert-error\">I want my approach to be more recreational than mathematical. Unfortunately, the following information doesn&#8217;t entirely come from reliable references and some is from my own experience:<br \/>\n<i class=\"icon-warning-sign\"><\/i> Don&#8217;t hesitate to bring more references in the comments.<\/div>\n<h2>Source code<\/h2>\n<p>I use glm library to manipulate matrix and quaternion. It&#8217;s free, it&#8217;s only headers (no lib or dll) and it&#8217;s cross-platform.<\/p>\n<p style=\"text-align: center;\"><a class=\"btn btn-primary btn-large\" href=\"https:\/\/glm.g-truc.net\" target=\"_blank\" rel=\"noopener\">Download glm<\/a><\/p>\n<p>Finally, I use macros EXPECT_EQ and others from <a href=\"https:\/\/github.com\/google\/googletest\">Google Test<\/a>.<\/p>\n<p>All following examples are inside my GitHub <a href=\"https:\/\/github.com\/Rominitch\/myBlogSource\/\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/Rominitch\/myBlogSource\/<\/a>, see Matrix_Quaternion.<\/p>\n<h2>Notation<\/h2>\n<p>In the following examples, I will use the following writing convention:<\/p>\n<ul>\n<li>Left to right multiplication<\/li>\n<li>Row-major order for matrix<\/li>\n<\/ul>\n<div class=\"well well-small\" style=\"text-align: center;\">\n<div class='content-column one_fifth'><h4>Simple notation<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-ebdb6d1b123151ff52ff7075b1b72686_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#114;&#125;&#32;&#61;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#109;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#118;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"9\" width=\"78\" style=\"vertical-align: 0px;\"\/><br \/><\/div>\n<div class='content-column two_fifth'><h4>Extend notation<\/h4>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 116px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-2fa05004f84263fecda803686527fd67_l3.png\" height=\"116\" width=\"316\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\" &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#38;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#109;&#95;&#123;&#48;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#49;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#50;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#51;&#125;&#32;&#92;&#92; &#109;&#95;&#123;&#52;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#53;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#54;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#55;&#125;&#32;&#92;&#92; &#109;&#95;&#123;&#56;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#57;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#49;&#48;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#49;&#49;&#125;&#32;&#92;&#92; &#109;&#95;&#123;&#49;&#50;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#49;&#51;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#49;&#52;&#125;&#32;&#38;&#32;&#109;&#95;&#123;&#49;&#53;&#125; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#92;&#92; &#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#118;&#95;&#123;&#48;&#125;&#32;&#38;&#32;&#118;&#95;&#123;&#49;&#125;&#32;&#38;&#32;&#118;&#95;&#123;&#50;&#125;&#32;&#38;&#32;&#118;&#95;&#123;&#51;&#125; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#38;&#32;&#92;&#109;&#115;&#112;&#97;&#99;&#101;&#123;&#53;&#109;&#117;&#125; &#92;&#98;&#105;&#103;&#108;&#091;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#109;&#95;&#123;&#49;&#50;&#125;&#36;&#125;&#093;&#123;&#36;&#114;&#95;&#123;&#48;&#125;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#109;&#95;&#123;&#49;&#51;&#125;&#36;&#125;&#093;&#123;&#36;&#114;&#95;&#123;&#49;&#125;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#109;&#95;&#123;&#49;&#52;&#125;&#36;&#125;&#093;&#123;&#36;&#114;&#95;&#123;&#50;&#125;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#109;&#95;&#123;&#49;&#53;&#125;&#36;&#125;&#093;&#123;&#36;&#114;&#95;&#123;&#51;&#125;&#36;&#125; &#92;&#101;&#110;&#100;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#92;&#109;&#115;&#112;&#97;&#99;&#101;&#123;&#53;&#109;&#117;&#125; &#92;&#98;&#105;&#103;&#114;&#093; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; \" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/div>\n<div class='content-column two_fifth last_column'><h4>Equivalent source code<\/h4>\n<pre class=\"lang:default decode:true \">glm::mat4 matrix(0.0f, 1.0f, 0.0f, 0.0f,\r\n                 1.0f, 0.0f, 0.0f, 0.0f,\r\n                 0.0f, 0.0f, 1.0f, 0.0f,\r\n                 0.0f, 0.0f, 0.0f, 1.0f);\r\nglm::vec4 vector(2.0f, 3.0f, 4.0f, 1.0f);\r\nglm::vec4 result = matrix * vector;<\/pre><\/div><div class='clear_column'><\/div>\n<\/div>\n<div class=\"alert alert-info\" role=\"alert\">Indices 0,1,2,3, &#8230; point to memory address.<\/div>\n<p>So we can write: <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-6ed561f7dfca4198486993859de11525_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#109;&#118;&#112;&#125;&#32;&#61;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#112;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#40;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#118;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#109;&#125;&#41;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"147\" style=\"vertical-align: -4px;\"\/><\/p>\n<div class=\"well well-small\" style=\"text-align: center;\">\n<div class='content-column one_half'><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-763bfde6e0efa9082b5c9e7057be61e8_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#114;&#114;&#97;&#121;&#125;&#123;&#99;&#99;&#99;&#125; &#126;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#123;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#118;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#112;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#125;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#123;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#109;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#67;&#125;&#123;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#109;&#118;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#109;&#118;&#112;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#114;&#114;&#97;&#121;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"44\" width=\"144\" style=\"vertical-align: -18px;\"\/><br \/><\/div>\n<div class='content-column one_half last_column'><pre class=\"lang:default decode:true\">glm::mat4 m(0.5f, 0.0f, 0.0f, 0.0f,\r\n            0.0f, 0.5f, 0.0f, 0.0f,\r\n            0.0f, 0.0f, 0.5f, 0.0f,\r\n            0.0f, 0.0f, 0.0f, 1.0f);\r\nglm::mat4 v(0.0f, 1.0f, 0.0f, 0.0f,\r\n            1.0f, 0.0f, 0.0f, 0.0f,\r\n            0.0f, 0.0f, 1.0f, 0.0f,\r\n            0.0f, 0.0f, 0.0f, 1.0f);\r\nglm::mat4 p(1.0f, 0.0f, 0.0f, 0.0f,\r\n            0.0f, 1.0f, 0.0f, 0.0f,\r\n            0.0f, 0.0f, 1.0f, 0.0f,\r\n            1.0f, 2.0f, 3.0f, 1.0f);\r\n\r\nglm::mat4 result = p * v * m;\r\nglm::mat4 mvp(0.0f, 0.5f, 0.0f, 0.0f,\r\n              0.5f, 0.0f, 0.0f, 0.0f,\r\n              0.0f, 0.0f, 0.5f, 0.0f,\r\n              1.0f, 2.0f, 3.0f, 1.0f);\r\nEXPECT_EQ(mvp, result);\r\nEXPECT_NE(mvp, m * v * p);\r\n<\/pre><\/div><div class='clear_column'><\/div>\n<\/div>\n<p>I don&#8217;t know if it is a &#8220;true&#8221; mathematical writing convention but it&#8217;s similar to code and c++\/glm order.<\/p>\n<p>For simplification reasons and to have more readable diagrams, we work in Z=0 plane.<br \/>\nWe stay in 3D in our logic as well as in our formula.<\/p>\n<p>I have an orthonormal system O with its <span style=\"color: #ff0000;\">X axis<\/span> and its <span style=\"color: #339966;\">Y axis<\/span>, Z is oriented toward us.<br \/>\nUnits depend on the size of x and y vectors.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-149 aligncenter\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/classic_repere-290x216.png\" alt=\"\" width=\"290\" height=\"216\" \/><br \/>\nIn short, it&#8217;s classic.<\/p>\n<h1>Transformation matrices<\/h1>\n<p>The transformation matrices containing homogeneous coordinates (that we call matrices afterward) allow us to apply a geometric transformation (more or less complexe) to point or vector.<\/p>\n<p>I suppose you either know how to manipulate (basically realize sum\/multiplication\/transpose\/invert) or your software\/library can do it for you !<\/p>\n<h2>Remind: major forms<\/h2>\n<p>Here, you can find the major forms of transformation matrix we want to use:<br \/>\n<div class='content-column one_third'><h4>Translation T<\/h4><\/div><\/p>\n<div class='content-column one_third'><h4>Rotation R<\/h4><\/div>\n<div class='content-column one_third last_column'><h4>Homothetic or Scaling S<\/h4><\/div><div class='clear_column'><\/div>\n<div class='content-column one_third'><div class=\"well well-small\" style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-07933042648f32d4bdba63201941633f_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#116;&#95;&#123;&#48;&#125;&#32;&#38;&#32;&#116;&#95;&#123;&#49;&#125;&#32;&#38;&#32;&#116;&#95;&#123;&#50;&#125;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"86\" width=\"114\" style=\"vertical-align: -39px;\"\/><\/div><\/div>\n<div class='content-column one_third'><div class=\"well well-small\" style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-5456a53614b4a3db3d845949ea88f94f_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#114;&#95;&#123;&#48;&#125;&#32;&#38;&#32;&#114;&#95;&#123;&#49;&#125;&#32;&#38;&#32;&#114;&#95;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#114;&#95;&#123;&#52;&#125;&#32;&#38;&#32;&#114;&#95;&#123;&#53;&#125;&#32;&#38;&#32;&#114;&#95;&#123;&#54;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#114;&#95;&#123;&#56;&#125;&#32;&#38;&#32;&#114;&#95;&#123;&#57;&#125;&#32;&#38;&#32;&#114;&#95;&#123;&#49;&#48;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"86\" width=\"125\" style=\"vertical-align: -39px;\"\/><\/div><\/div>\n<div class='content-column one_third last_column'><div class=\"well well-small\" style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-e5c5294815939e749f4b7fd3027d6f5e_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#115;&#95;&#123;&#48;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#115;&#95;&#123;&#49;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#115;&#95;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"86\" width=\"119\" style=\"vertical-align: -39px;\"\/><\/div><\/div><div class='clear_column'><\/div>\n<h2>Problem 1: What are transformation matrix ? and how to make them ?<\/h2>\n<h3>Translation and matrix representation<\/h3>\n<p>We will start with a rather naive approach. To start with we will try to translate a 3D point.<br \/>\nOn this diagram, I want to translate my point A to B.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"wp-image-92 size-medium aligncenter\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/translation-1-300x228.png\" alt=\"\" width=\"300\" height=\"228\" srcset=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/translation-1-300x228.png 300w, http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/translation-1.png 340w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>We can easily read <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-3bdc660f383432c74d2321422ddf7cc0_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#65;&#40;&#49;&#44;&#32;&#49;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"69\" style=\"vertical-align: -4px;\"\/> and <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-40460bb976a15091ee90b612c868baed_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#79;&#125;&#66;&#40;&#51;&#44;&#32;&#50;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"70\" style=\"vertical-align: -4px;\"\/> so translation vector is <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-548587ebbc13ec40e3161ed60dc5d60c_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#92;&#118;&#101;&#99;&#123;&#65;&#66;&#125;&#40;&#50;&#44;&#32;&#49;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"83\" style=\"vertical-align: -4px;\"\/>.<br \/>\nWe substitute the &#8220;t&#8221; values of the matrix by this vector and compute the multiplication with A.<\/p>\n<div class=\"well well-small\" style=\"text-align: center;\"><div class='content-column one_half'><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-177a851540e1939acd20b7e9d03ea7c8_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#114;&#114;&#97;&#121;&#125;&#123;&#99;&#32;&#99;&#125; &#126;&#32;&#38;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#49;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#48;&#125;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#49;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#79;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#51;&#32;&#38;&#32;&#50;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#114;&#114;&#97;&#121;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"109\" width=\"215\" style=\"vertical-align: -51px;\"\/><br \/><\/div><div class='content-column one_half last_column'><pre class=\"lang:default decode:true \">glm::vec4 b( 3.0f, 2.0f, 0.0f, 1.0f);\r\n\r\nglm::vec4 a( 1.0f, 1.0f, 0.0f, 1.0f);\r\nglm::mat4 t( 1.0f, 0.0f, 0.0f, 0.0f,\r\n             0.0f, 1.0f, 0.0f, 0.0f,\r\n             0.0f, 0.0f, 1.0f, 0.0f,\r\n             2.0f, 1.0f, 0.0f, 1.0f );\r\nEXPECT_EQ( b, t * a );\r\n\r\nglm::mat4 t2( 1.0f ); \/\/ Identity\r\nt2 = glm::translate( t2, glm::vec3( 2.0f, 1.0f, 0.0f ) );\r\nEXPECT_EQ( b, t2 * a );\r\n<\/pre><\/div><div class='clear_column'><\/div><\/p>\n<\/div>\n<p>Finally, we retrieve our point B but &#8230;<\/p>\n<ul>\n<li>It looks like it worked, but what really happended ?<\/li>\n<li>Is it really more complex than applying a translation vector ?<\/li>\n<li>What did we use the other parts of the matrix for ?<\/li>\n<\/ul>\n<p>Now things are getting more difficult because we don&#8217;t actually apply a translation. It&#8217;s more like changing our point of view. We are looking at the same object but from a different place.<\/p>\n<p>Actually, matrices allow to change the coordinate system.<\/p>\n<p>I call <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-9acfdb439811e942bc31780c78f8ac04_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#109;&#97;&#116;&#104;&#115;&#99;&#114;&#123;&#77;&#125;&#95;&#123;&#88;&#92;&#118;&#101;&#99;&#123;&#120;&#125;&#92;&#118;&#101;&#99;&#123;&#121;&#125;&#92;&#118;&#101;&#99;&#123;&#122;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"20\" width=\"55\" style=\"vertical-align: -6px;\"\/> system, a system defined by X origin and <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-6d07f41815847b6233f1b347bb8a18e5_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#118;&#101;&#99;&#123;&#120;&#125;&#92;&#118;&#101;&#99;&#123;&#121;&#125;&#92;&#118;&#101;&#99;&#123;&#122;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"31\" style=\"vertical-align: -4px;\"\/> basis.<\/p>\n<p>The real form is:<br \/>\n<div class='content-column full_width'><div class=\"well well-small\" style=\"text-align: center;\">\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 87px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-2e3a0321a8a6a2bb1a17110cf01101bb_l3.png\" height=\"87\" width=\"386\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#118;&#101;&#99;&#116;&#101;&#117;&#114;&#32;&#120;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#123;&#118;&#101;&#99;&#116;&#101;&#117;&#114;&#32;&#121;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#118;&#101;&#99;&#116;&#101;&#117;&#114;&#32;&#122;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#112;&#111;&#115;&#105;&#116;&#105;&#111;&#110;&#32;&#100;&#97;&#110;&#115;&#32;&#108;&#101;&#32;&#109;&#111;&#110;&#100;&#101;&#125;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#61;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#120;&#95;&#123;&#48;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#120;&#95;&#123;&#49;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#120;&#95;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#123;&#121;&#95;&#123;&#48;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#123;&#121;&#95;&#123;&#49;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#123;&#121;&#95;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#122;&#95;&#123;&#48;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#122;&#95;&#123;&#49;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#122;&#95;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#77;&#95;&#123;&#48;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#77;&#95;&#123;&#49;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#77;&#95;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#49;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; \" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<\/div><\/div><\/p>\n<p>This is the &#8220;actual&#8221; diagram of what happened:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"wp-image-89 size-medium aligncenter\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/repere-1-300x229.png\" alt=\"\" width=\"300\" height=\"229\" srcset=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/repere-1-300x229.png 300w, http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/repere-1.png 340w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>In fact, our translation matrix will create another basis M with x,y,z vectors similar to O basis. We notice that:<\/p>\n<ul>\n<li><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-fef4c241ffabd74a2c445cf04c92d465_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#118;&#101;&#99;&#123;&#79;&#65;&#125;&#32;&#61;&#32;&#92;&#118;&#101;&#99;&#123;&#77;&#66;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"84\" style=\"vertical-align: 0px;\"\/> so the initial drawing (here just a point) doesn&#8217;t move in relation to basis.<\/li>\n<li>B coordinates are written in <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-d8902e1585c503437d146cbd8bdebb79_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#79;&#92;&#118;&#101;&#99;&#123;&#120;&#125;&#92;&#118;&#101;&#99;&#123;&#121;&#125;&#92;&#118;&#101;&#99;&#123;&#122;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"45\" style=\"vertical-align: -4px;\"\/> basis.<\/li>\n<\/ul>\n<p>There is sill one last question we need to answer: If B coordinates are written in O basis, in which basis is A written ?<\/p>\n<p>The answer is simple: inside M basis.<\/p>\n<div class='content-column one_third'>1. I have a 3D object: a bot made under computer graphics software (example: Blender).<br \/>\nIt has its own system<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-dd8a1041431498a8e3e4cb5f794533bd_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#109;&#97;&#116;&#104;&#115;&#99;&#114;&#123;&#83;&#125;&#95;&#123;&#82;&#92;&#118;&#101;&#99;&#123;&#115;&#125;&#92;&#118;&#101;&#99;&#123;&#116;&#125;&#92;&#118;&#101;&#99;&#123;&#114;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"46\" style=\"vertical-align: -6px;\"\/> and a point <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-02248713abd724916eb29955a38b0da3_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#69;&#40;&#49;&#44;&#32;&#49;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"69\" style=\"vertical-align: -4px;\"\/> representing the eye.<br \/><\/div>\n<div class='content-column one_third'>2. My aim is to use it inside my software which has the main coordinate system <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-0acdae408810d8e971b4a3dfb2881588_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#109;&#97;&#116;&#104;&#115;&#99;&#114;&#123;&#83;&#125;&#95;&#123;&#79;&#92;&#118;&#101;&#99;&#123;&#120;&#125;&#92;&#118;&#101;&#99;&#123;&#121;&#125;&#92;&#118;&#101;&#99;&#123;&#122;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"50\" style=\"vertical-align: -6px;\"\/>.<br \/>\nand another <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-78f6c055d6297564b1a76682f25e7932_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#109;&#97;&#116;&#104;&#115;&#99;&#114;&#123;&#83;&#125;&#95;&#123;&#77;&#92;&#118;&#101;&#99;&#123;&#117;&#125;&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#92;&#118;&#101;&#99;&#123;&#119;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"16\" width=\"56\" style=\"vertical-align: -3px;\"\/> which hierarchically depends from O because point M is defined in O system.<br \/><\/div>\n<div class='content-column one_third last_column'>3. If I draw my bot on O or M system (of course, we need to adapt to <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-dd8a1041431498a8e3e4cb5f794533bd_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#109;&#97;&#116;&#104;&#115;&#99;&#114;&#123;&#83;&#125;&#95;&#123;&#82;&#92;&#118;&#101;&#99;&#123;&#115;&#125;&#92;&#118;&#101;&#99;&#123;&#116;&#125;&#92;&#118;&#101;&#99;&#123;&#114;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"46\" style=\"vertical-align: -6px;\"\/>), I will transform my point E to A for O system or B for M system.<br \/><\/div><div class='clear_column'><\/div>\n<div class='content-column one_third'><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-153\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/robo1-1.png\" alt=\"\" width=\"202\" height=\"204\" srcset=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/robo1-1.png 202w, http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/robo1-1-150x150.png 150w\" sizes=\"auto, (max-width: 202px) 100vw, 202px\" \/><br \/><\/div>\n<div class='content-column one_third'><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-154\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/robo2-290x220.png\" alt=\"\" width=\"290\" height=\"220\" \/><br \/><\/div>\n<div class='content-column one_third last_column'><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-155\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/robo3-290x220.png\" alt=\"\" width=\"290\" height=\"220\" \/><br \/><\/div><div class='clear_column'><\/div>\n<p>Finally, we defined both O and M system. A point is defined in M system and B in O. Our matrix realized a transformation from M to O system.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-0acdae408810d8e971b4a3dfb2881588_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#109;&#97;&#116;&#104;&#115;&#99;&#114;&#123;&#83;&#125;&#95;&#123;&#79;&#92;&#118;&#101;&#99;&#123;&#120;&#125;&#92;&#118;&#101;&#99;&#123;&#121;&#125;&#92;&#118;&#101;&#99;&#123;&#122;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"50\" style=\"vertical-align: -6px;\"\/> is upper system of <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-78f6c055d6297564b1a76682f25e7932_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#109;&#97;&#116;&#104;&#115;&#99;&#114;&#123;&#83;&#125;&#95;&#123;&#77;&#92;&#118;&#101;&#99;&#123;&#117;&#125;&#92;&#118;&#101;&#99;&#123;&#118;&#125;&#92;&#118;&#101;&#99;&#123;&#119;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"16\" width=\"56\" style=\"vertical-align: -3px;\"\/> because M coordinates are defined in <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-0acdae408810d8e971b4a3dfb2881588_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#109;&#97;&#116;&#104;&#115;&#99;&#114;&#123;&#83;&#125;&#95;&#123;&#79;&#92;&#118;&#101;&#99;&#123;&#120;&#125;&#92;&#118;&#101;&#99;&#123;&#121;&#125;&#92;&#118;&#101;&#99;&#123;&#122;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"50\" style=\"vertical-align: -6px;\"\/> : we have a hierarchy notion.<\/p>\n<p>We have just added an important notion: the application way.<br \/>\nIn order to change it, we need to invert the matrix. Indeed, all the previous transformation matrices are invertible.<\/p>\n<div class=\"alert alert-success\" role=\"alert\">\n<p>To conclude:<\/p>\n<ul>\n<li>Matrices represent a change of basis between two systems in the same hierarchy<\/li>\n<li>Its has a way of application: up or down into hierarchy<\/li>\n<\/ul>\n<\/div>\n<p>For what follows, we will create all our matrix in this way: current to up because they are more intuitive to create.<\/p>\n<div class=\"alert alert-info\" role=\"alert\">In publication, you can read about Global\/World and Local (coordinate).<br \/>\nWorld is mainly the top of the hierarchy.<\/div>\n<h3>The rotation<\/h3>\n<p>The rotation matrix allows us to define the basis of our system. Each vector is normalized before being used inside the matrix.<br \/>\nWe have the following matrix:<\/p>\n<div class='content-column full_width'><div class=\"well well-small\" style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-080f6d2fbf2aef326de392b1ac7fc947_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#120;&#95;&#123;&#48;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#120;&#95;&#123;&#49;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#120;&#95;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#123;&#121;&#95;&#123;&#48;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#123;&#121;&#95;&#123;&#49;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#123;&#121;&#95;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#122;&#95;&#123;&#48;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#122;&#95;&#123;&#49;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#122;&#95;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"86\" width=\"125\" style=\"vertical-align: -39px;\"\/><\/div><\/div>\n<p>It&#8217;s very simple to write rotation matrix of <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-c696d1c7f980d95b8ec929b5ae774367_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#102;&#114;&#97;&#99;&#123;&#80;&#73;&#125;&#123;&#52;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"22\" width=\"18\" style=\"vertical-align: -6px;\"\/> around <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-fe25dcb2a0e83df97cac680b41305d43_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#118;&#101;&#99;&#123;&#122;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"13\" width=\"12\" style=\"vertical-align: 0px;\"\/>.<br \/>\nWe start with this diagram:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-91 aligncenter\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotation_without_norm-1-300x192.png\" alt=\"\" width=\"300\" height=\"192\" srcset=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotation_without_norm-1-300x192.png 300w, http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotation_without_norm-1.png 372w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Reading coordinate, we have <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-f2e361d60144419a94612f77b8cca1e1_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#92;&#118;&#101;&#99;&#123;&#120;&#125;&#32;&#61;&#32;&#40;&#49;&#44;&#32;&#49;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"89\" style=\"vertical-align: -4px;\"\/>, <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-97efbf16ed14e427fb3147368deb64d3_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#123;&#92;&#118;&#101;&#99;&#123;&#121;&#125;&#32;&#61;&#32;&#40;&#45;&#49;&#44;&#32;&#49;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"102\" style=\"vertical-align: -4px;\"\/>\u00a0and <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-884c8afd01570f08dbb8c26306ae71ba_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#92;&#118;&#101;&#99;&#123;&#122;&#125;&#32;&#61;&#32;&#40;&#48;&#44;&#32;&#48;&#44;&#32;&#49;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"88\" style=\"vertical-align: -4px;\"\/>.<br \/>\nI define <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-69766f98174d4d0603c07cff0544cf51_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#32;&#67;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#50;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"27\" width=\"59\" style=\"vertical-align: -11px;\"\/> soit <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-75b0b2a577972fb3271187e00abada15_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#118;&#101;&#99;&#116;&#111;&#114;&#32;&#108;&#101;&#110;&#103;&#116;&#104;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"25\" width=\"77\" style=\"vertical-align: -9px;\"\/> which allows me to normalize vectors.<\/p>\n<div class=\"alert alert-info\" role=\"alert\">In fact, <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-4daf823960f4c3a90149eccfe804856a_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#32;&#67;&#32;&#61;&#32;&#99;&#111;&#115;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#80;&#73;&#125;&#123;&#52;&#125;&#41;&#32;&#61;&#32;&#115;&#105;&#110;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#80;&#73;&#125;&#123;&#52;&#125;&#41;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#92;&#115;&#113;&#114;&#116;&#123;&#50;&#125;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"27\" width=\"226\" style=\"vertical-align: -11px;\"\/>. For those who know their rotation matrix around <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-76af122d9ba98d937403aa24a29883b7_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#118;&#101;&#99;&#123;&#90;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"13\" style=\"vertical-align: 0px;\"\/>, by hearth sin() et cos() are here.<\/div>\n<p>I integrate normalized vectors into the matrix and I have:<\/p>\n<div class=\"well well-small\" style=\"text-align: center;\"><div class='content-column one_half'><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-424aa16748423b6357f74743405002c1_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\" &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#67;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#67;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#48;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#123;&#45;&#67;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#123;&#67;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#123;&#48;&#32;&#125;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#48;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#48;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#49;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"86\" width=\"122\" style=\"vertical-align: -39px;\"\/><br \/><\/div><br \/>\n<div class='content-column one_half last_column'><pre class=\"lang:default decode:true \">const float pi_4 = 0.785398163397448309616f;\r\nconst float C = 1.0f \/ sqrt(2.0f);\r\n\/\/ Made hand matrix\r\nglm::mat4 r( C,    C,    0.0f, 0.0f,\r\n            -C,    C,    0.0f, 0.0f,\r\n             0.0f, 0.0f, 1.0f, 0.0f,\r\n             0.0f, 0.0f, 0.0f, 1.0f);\r\n    \r\n\/\/ Or using glm\r\nglm::mat4 r1(1.0f); \/\/ Identity\r\nr1 = glm::rotate(r1, pi_4, glm::vec3(0.0f, 0.0f, 1.0f));\r\n       \r\nEXPECT_EQ(r, r1);\r\n<\/pre><\/div><div class='clear_column'><\/div><\/p>\n<\/div>\n<p>Let&#8217;s try to play with this example:\u00a0<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-acb32d2f47d7493b7fd7205c2a0c28fc_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#65;&#32;&#61;&#32;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#50;&#125;&#123;&#51;&#125;&#44;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#51;&#125;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"22\" width=\"96\" style=\"vertical-align: -6px;\"\/> and <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-5d3e44d8a8406551ca06e68e6b859e5e_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#66;&#32;&#61;&#32;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#67;&#125;&#123;&#51;&#125;&#44;&#32;&#67;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"22\" width=\"103\" style=\"vertical-align: -6px;\"\/> (it is simple enough to compute using Pythagore theorem only and in noticing than OA = y coordinate of point B)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-93 size-medium aligncenter\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotation_point-1-300x215.png\" alt=\"\" width=\"300\" height=\"215\" srcset=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotation_point-1-300x215.png 300w, http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotation_point-1.png 311w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<div class=\"well well-small\" style=\"text-align: center;\"><div class='content-column one_half'><p class=\"ql-center-displayed-equation\" style=\"line-height: 116px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-4b45b3956ba66dced3792ae94e7e9690_l3.png\" height=\"116\" width=\"230\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\" &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#38;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#32;&#67;&#125;&#32;&#38;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#67;&#125;&#32;&#38;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#48;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#45;&#67;&#125;&#32;&#38;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#67;&#125;&#32;&#38;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#89;&#125;&#48;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#32;&#48;&#125;&#32;&#38;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#48;&#125;&#32;&#38;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#49;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#92; &#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#92;&#102;&#114;&#97;&#99;&#123;&#50;&#125;&#123;&#51;&#125;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#51;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#38;&#32;&#92;&#109;&#115;&#112;&#97;&#99;&#101;&#123;&#53;&#109;&#117;&#125; &#92;&#98;&#105;&#103;&#108;&#091;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#45;&#67;&#36;&#125;&#093;&#123;&#36;&#92;&#102;&#114;&#97;&#99;&#123;&#67;&#125;&#123;&#51;&#125;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#67;&#36;&#125;&#093;&#123;&#36;&#67;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#48;&#36;&#125;&#093;&#123;&#48;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#49;&#36;&#125;&#093;&#123;&#49;&#125; &#92;&#101;&#110;&#100;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#92;&#109;&#115;&#112;&#97;&#99;&#101;&#123;&#53;&#109;&#117;&#125; &#92;&#98;&#105;&#103;&#114;&#093; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; \" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/div><br \/>\n<div class='content-column one_half last_column'><pre class=\"lang:default decode:true \">const float C = 1.0f \/ sqrt(2.0f);\r\nglm::mat4 r( C,   C,    0.0f, 0.0f,\r\n            -C,   C,    0.0f, 0.0f,\r\n            0.0f, 0.0f, 1.0f, 0.0f,\r\n            0.0f, 0.0f, 0.0f, 1.0f);\r\n\r\nglm::vec4 a(2.0f\/3.0f, 1.0f\/3.0f, 0.0f, 1.0f);\r\nglm::vec4 b(   C\/3.0f, C,         0.0f, 1.0f);\r\n\r\nEXPECT_EQ(b, r * a);\r\n<\/pre><\/div><div class='clear_column'><\/div><\/p>\n<\/div>\n<p>Perfect ! We did it !<\/p>\n<div class=\"alert alert-success\" role=\"alert\">\n<p>Some remarks:<\/p>\n<ul>\n<li>Rotation turns around the origin of R.<\/li>\n<li>We can &#8220;easily&#8221; verify that a matrix is correct (see if X\/Y\/Z vector is positive\/negative on each component).<\/li>\n<li>B coordinates are <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-d8902e1585c503437d146cbd8bdebb79_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#79;&#92;&#118;&#101;&#99;&#123;&#120;&#125;&#92;&#118;&#101;&#99;&#123;&#121;&#125;&#92;&#118;&#101;&#99;&#123;&#122;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"45\" style=\"vertical-align: -4px;\"\/> system (as expected).<\/li>\n<\/ul>\n<\/div>\n<p>On complex model (many points), rotation will give you:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-90 size-medium aligncenter\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotation-1-300x219.png\" alt=\"\" width=\"300\" height=\"219\" srcset=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotation-1-300x219.png 300w, http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotation-1.png 318w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><br \/>\nAnother question is raised: how to turn around another point ? Ok &#8230; I leave it for now but you have the reply at the end of the post.<\/p>\n<h4>and finally homothetic transformation<\/h4>\n<p>Here, we want to &#8220;stretch&#8221; our object into each dimension. For that, we applied on each basis&#8217; vector a scaling factor.<br \/>\nEach scaling factor is defined in <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-2e13eb3923d259cfa740699955ee93a3_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#109;&#97;&#116;&#104;&#98;&#98;&#123;&#82;&#125;&#95;&#123;&#43;&#125;&#94;&#123;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"23\" style=\"vertical-align: -6px;\"\/>.<br \/>\nWhen superior to 1 : we increase, and between 0 and 1 : we reduce.<\/p>\n<p>In this example, we try to reduce or system by two in all dimensions.<br \/>\nThis time we take two points in order to see what happens.<\/p>\n<ul>\n<li>A will become C<\/li>\n<li>B will become D<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-81 aligncenter\" src=\"https:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/scaling.png\" alt=\"\" width=\"295\" height=\"251\" \/><\/p>\n<div class=\"well well-small\" style=\"text-align: center;\"><div class='content-column one_half'><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-66ef460c919c04e785cb752f83e80391_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#114;&#114;&#97;&#121;&#125;&#123;&#99;&#32;&#99;&#125; &#126;&#32;&#38;&#32;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#48;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#48;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#92;&#102;&#114;&#97;&#99;&#123;&#50;&#125;&#123;&#51;&#125;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#51;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#79;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#51;&#125;&#32;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#54;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#92;&#92; &#126;&#32;&#38;&#32;&#126;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#49;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#51;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#79;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#54;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#92;&#101;&#110;&#100;&#123;&#97;&#114;&#114;&#97;&#121;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"155\" width=\"224\" style=\"vertical-align: -73px;\"\/><br \/><\/div><br \/>\n<div class='content-column one_half last_column'><pre class=\"lang:default decode:true \">glm::vec3 h(0.5f, 0.5f, 0.5f);\r\nglm::mat4 m(h.x,  0.0f, 0.0f, 0.0f,\r\n            0.0f, h.y,  0.0f, 0.0f,\r\n            0.0f, 0.0f, h.z,  0.0f,\r\n            0.0f, 0.0f, 0.0f, 1.0f);\r\n\r\nglm::mat4 m1(1.0f); \/\/ Identity\r\nm1 = glm::scale(m1, h);\r\nEXPECT_EQ(m1, m);\r\n\r\nglm::vec4 a(2.0f\/3.0f, 1.0f\/3.0f, 0.0f, 1.0f);\r\nglm::vec4 b(1.0f, 1.0f\/3.0f, 0.0f, 1.0f);\r\n\r\nglm::vec4 c(1.0f\/3.0f, 1.0f\/6.0f, 0.0f, 1.0f);\r\nglm::vec4 d(1.0f\/2.0f, 1.0f\/6.0f, 0.0f, 1.0f);\r\n\r\nEXPECT_EQ(c, m * a);\r\nEXPECT_EQ(d, m * b);\r\n<\/pre><\/div><div class='clear_column'><\/div><\/p>\n<\/div>\n<p>To conclude, let&#8217;s try it on our robot.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-82 aligncenter\" src=\"https:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/scaling_object.png\" alt=\"\" width=\"270\" height=\"246\" \/><\/p>\n<div class=\"alert alert-success\" role=\"alert\">\n<p>Some remarks:<\/p>\n<ul>\n<li>C and D coordinates are in <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-d8902e1585c503437d146cbd8bdebb79_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#79;&#92;&#118;&#101;&#99;&#123;&#120;&#125;&#92;&#118;&#101;&#99;&#123;&#121;&#125;&#92;&#118;&#101;&#99;&#123;&#122;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"45\" style=\"vertical-align: -4px;\"\/> system.<\/li>\n<li>Our robot has not moved according to his coordinate system: C coordinates are always at <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-d3b766245d69c7b7ccf6b63420b0fa46_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#102;&#114;&#97;&#99;&#123;&#50;&#125;&#123;&#51;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"22\" width=\"7\" style=\"vertical-align: -6px;\"\/> of X vector and D at the end of the vector.<\/li>\n<\/ul>\n<\/div>\n<p>To conclude this first part, we saw than matrix creation is not really complicated despite the fact that rotation demands some computation but analize is accessible (during debug phase).<\/p>\n<h2>Problem 2: Composition<\/h2>\n<p>Generally, the most important is to quickly\u00a0 apply all these operations to our billion points. So the main idea is to create only one matrix with allthe operations inside.<br \/>\nTo create them we use composition which is a multiplication between matrices.<\/p>\n<div class=\"alert alert-block\">Important thing:<br \/>\nMATRIX PRODUCT IS NOT COMMUTATIVE: <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-5aba3e49bd192e3b8db5d9fdfa5a8d01_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#32;&#109;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#110;&#32;&#92;&#110;&#101;&#113;&#32;&#110;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#109;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"119\" style=\"vertical-align: -4px;\"\/> !<\/div>\n<p>First we try to compose each matrix which define a complete system (translation \/ rotation \/ homothetic).<br \/>\nSo, the order of the operations are very important but the rules are simple:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-2ca4935a68f2e981094128cd03bfce4f_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#67;&#111;&#109;&#112;&#111;&#115;&#105;&#116;&#105;&#111;&#110;&#125;&#32;&#61;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#84;&#114;&#97;&#110;&#115;&#108;&#97;&#116;&#105;&#111;&#110;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#40;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#82;&#111;&#116;&#97;&#116;&#105;&#111;&#110;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#123;&#72;&#111;&#109;&#111;&#116;&#104;&#101;&#116;&#105;&#99;&#125;&#41;&#32;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"442\" style=\"vertical-align: -4px;\"\/><\/p>\n<p>So to simplify this post, I will call them: matrices HRT.<br \/>\nAs usual, I will take a example to see what happens.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-96 aligncenter\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/composition_simple-300x194.png\" alt=\"\" width=\"300\" height=\"194\" srcset=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/composition_simple-300x194.png 300w, http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/composition_simple.png 416w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Ok, first, we compute composition.<\/p>\n<div class=\"well well-small\" style=\"text-align: center;\"><div class='content-column one_third'><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-b2b819e885bdc26cfd9608a72cbff4ed_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#114;&#114;&#97;&#121;&#125;&#123;&#99;&#32;&#99;&#32;&#99;&#125; &#126;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#45;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#38; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#102;&#114;&#97;&#99;&#123;&#49;&#49;&#125;&#123;&#54;&#125;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#38; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#48;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#45;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#38; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#48;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#45;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#102;&#114;&#97;&#99;&#123;&#49;&#49;&#125;&#123;&#54;&#125;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#114;&#114;&#97;&#121;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"174\" width=\"390\" style=\"vertical-align: -83px;\"\/><br \/><\/div><br \/>\n<div class='content-column two_third last_column'><pre class=\"lang:default decode:true \">const float PI = 3.14159265358979323846f;\r\n\r\nglm::mat4 s = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f, 0.5f, 0.5f));\r\nglm::mat4 r = glm::rotate(glm::mat4(1.0f), PI*0.5f, glm::vec3(0.0f, 0.0f, 1.0f));\r\nglm::mat4 t = glm::translate(glm::mat4(1.0f), glm::vec3(11.0f\/6.0f, 0.5f, 0.0f));\r\n    \r\nglm::mat4 m(0.0f,       0.5f, 0.0f, 0.0f,\r\n           -0.5f,       0.0f, 0.0f, 0.0f,\r\n            0.0f,       0.0f, 0.5f, 0.0f,\r\n            11.0f\/6.0f, 0.5f, 0.0f, 1.0f);\r\nglm::mat4 c = t * r * s;\r\n    \r\n\/\/ Near expected\r\nfor(int rawID=0; rawID &lt; 4; ++rawID)\r\n{\r\n    for(int columnID=0; columnID &lt; 4; ++columnID)\r\n    {\r\n        EXPECT_NEAR(m[rawID][columnID], c[rawID][columnID], 1e-6f);\r\n    }\r\n}\r\n<\/pre><\/div><div class='clear_column'><\/div><\/p>\n<\/div>\n<p>If we use it on <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-dbb19a78e088df59e0ee9268cff9e26b_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#65;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"12\" width=\"13\" style=\"vertical-align: 0px;\"\/>.<\/p>\n<div class=\"well well-small\" style=\"text-align: center;\"><div class='content-column one_half'><p class=\"ql-center-displayed-equation\" style=\"line-height: 117px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-5bc271507db4401c3132b0182e7069db_l3.png\" height=\"117\" width=\"222\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\" &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#48;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#45;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#92;&#102;&#114;&#97;&#99;&#123;&#49;&#49;&#125;&#123;&#54;&#125;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#125; &#92;&#92; &#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#92;&#102;&#114;&#97;&#99;&#123;&#50;&#125;&#123;&#51;&#125;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#51;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#38;&#32;&#92;&#109;&#115;&#112;&#97;&#99;&#101;&#123;&#53;&#109;&#117;&#125; &#92;&#98;&#105;&#103;&#108;&#091;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#45;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#36;&#125;&#093;&#123;&#36;&#92;&#102;&#114;&#97;&#99;&#123;&#53;&#125;&#123;&#51;&#125;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#50;&#125;&#36;&#125;&#093;&#123;&#36;&#92;&#102;&#114;&#97;&#99;&#123;&#53;&#125;&#123;&#54;&#125;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#48;&#36;&#125;&#093;&#123;&#48;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#49;&#36;&#125;&#093;&#123;&#49;&#125; &#92;&#101;&#110;&#100;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#92;&#109;&#115;&#112;&#97;&#99;&#101;&#123;&#53;&#109;&#117;&#125; &#92;&#98;&#105;&#103;&#114;&#093; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; \" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/div><br \/>\n<div class='content-column one_half last_column'><pre class=\"lang:default decode:true \">glm::mat4 m(0.0f,       0.5f, 0.0f, 0.0f,\r\n           -0.5f,       0.0f, 0.0f, 0.0f,\r\n            0.0f,       0.0f, 0.5f, 0.0f,\r\n            11.0f\/6.0f, 0.5f, 0.0f, 1.0f);\r\nglm::vec4 a(2.0f\/3.0f, 1.0f\/3.0f, 0.0f, 1.0f);\r\nglm::vec4 b(5.0f\/3.0f, 5.0f\/6.0f, 0.0f, 1.0f);\r\n\r\nglm::vec4 mul = m * a;\r\n    \r\n\/\/ Near expected\r\nfor(int columnID=0; columnID &lt; 4; ++columnID)\r\n{\r\n    EXPECT_NEAR(b[columnID], mul[columnID], 1e-6f);\r\n}\r\n<\/pre><\/div><div class='clear_column'><\/div><\/p>\n<\/div>\n<p>Now, we can &#8220;translate&#8221; complex system to matrix, but we need to compose many systems based on hierarchy. So we take another example.<\/p>\n<h2>Turn around another point<\/h2>\n<p>Previously, I told you rotation matrix turn around the origin of a local system. Sometime we need to change it: I will show you the methodology.<\/p>\n<div class='content-column one_third'>1. We have the following model; we want to turn around B.<\/div>\n<div class='content-column one_third'>2. We translate B to the origin of local system, in this case <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-84e29a1e75d28d8525aa21a3d0fd0209_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#118;&#101;&#99;&#123;&#66;&#79;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"28\" style=\"vertical-align: 0px;\"\/>.<\/div>\n<div class='content-column one_third last_column'>3. We apply rotation matrix as usually.<\/div><div class='clear_column'><\/div>\n<div class='content-column one_third'><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-178 \" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotate1.png\" alt=\"\" width=\"305\" height=\"266\" \/><\/div>\n<div class='content-column one_third'><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-179 size-full\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotate2.png\" alt=\"\" width=\"229\" height=\"281\" \/><\/div>\n<div class='content-column one_third last_column'><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-180\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotate3-206x220.png\" alt=\"\" width=\"206\" height=\"220\" \/><\/div><div class='clear_column'><\/div>\n<div class='content-column full_width'>4. We apply opposite translation, so <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-518be52fc2717b229c6fe4b45cbf209d_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#118;&#101;&#99;&#123;&#79;&#66;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"28\" style=\"vertical-align: 0px;\"\/>.<\/div>\n<div class='content-column full_width'><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-181\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotate4-290x220.png\" alt=\"\" width=\"290\" height=\"220\" \/><\/div>\n<p>Finally, we realize: one translation + one rotation + one translation.<br \/>\nWe see how to make HRT matrix but can we combine more of them?<\/p>\n<p>Let&#8217;s try:<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-9a3906b5e1aa679dc10eb8e04be02e6c_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#67;&#111;&#109;&#112;&#111;&#115;&#105;&#116;&#105;&#111;&#110;&#125;&#32;&#61;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#84;&#114;&#97;&#110;&#115;&#108;&#97;&#116;&#105;&#111;&#110;&#92;&#118;&#101;&#99;&#123;&#79;&#80;&#125;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#40;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#82;&#111;&#116;&#97;&#116;&#105;&#111;&#110;&#125;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#123;&#84;&#114;&#97;&#110;&#115;&#108;&#97;&#116;&#105;&#111;&#110;&#92;&#118;&#101;&#99;&#123;&#80;&#79;&#125;&#125;&#41;&#32;\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"500\" style=\"vertical-align: -4px;\"\/><\/p>\n<p>Using this example: <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-e9130d3769137e6ff990df179bc1e1f7_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#65;&#40;&#49;&#44;&#32;&#50;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"69\" style=\"vertical-align: -4px;\"\/> and <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-e223b036f6a0c22b5f08a6b79ca49896_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#66;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#52;&#125;&#123;&#51;&#125;&#44;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#52;&#125;&#123;&#51;&#125;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"22\" width=\"74\" style=\"vertical-align: -6px;\"\/> some points of our object, we try to apply a rotation of <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-b40d4729101107a208fc1dfcffeb5002_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#112;&#105;&#125;&#123;&#50;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"9\" style=\"vertical-align: -6px;\"\/> around A.<br \/>\nWe expect <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-cceeb0aebf6e1ebb028eaa72a383406f_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#67;&#40;&#49;&#44;&#32;&#50;&#44;&#32;&#48;&#41;&#32;&#61;&#32;&#65;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"107\" style=\"vertical-align: -4px;\"\/> and <img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-84f0caa4f354dd1248487a49d35419d7_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#79;&#125;&#68;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#53;&#125;&#123;&#51;&#125;&#44;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#55;&#125;&#123;&#51;&#125;&#44;&#32;&#48;&#41;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"22\" width=\"74\" style=\"vertical-align: -6px;\"\/><\/p>\n<p><div class='content-column one_half'><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-190 size-full aligncenter\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotatePoint1.png\" alt=\"\" width=\"266\" height=\"364\" \/><br \/><\/div><br \/>\n<div class='content-column one_half last_column'><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-191 size-full\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/rotatePoint2.png\" alt=\"\" width=\"255\" height=\"400\" \/><br \/><\/div><div class='clear_column'><\/div><\/p>\n<p>Start with composition matrix:<\/p>\n<div class=\"well well-small\" style=\"text-align: center;\"><div class='content-column one_third'><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-1ca3e559c80ea733a8bdfaee263f9115_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#114;&#114;&#97;&#121;&#125;&#123;&#99;&#32;&#99;&#32;&#99;&#125; &#126;&#32;&#38;&#32;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#82;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#45;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#38; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#66;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#49;&#32;&#38;&#32;&#50;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#32;&#92;&#92; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#45;&#49;&#32;&#38;&#32;&#45;&#50;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125;&#32;&#38; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#45;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#50;&#32;&#38;&#32;&#45;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#32;&#38; &#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#45;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#51;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#114;&#114;&#97;&#121;&#125; \" title=\"Rendered by QuickLaTeX.com\" height=\"174\" width=\"415\" style=\"vertical-align: -83px;\"\/><br \/><\/div><br \/>\n<div class='content-column two_third last_column'><pre class=\"lang:default decode:true \">const float PI = 3.14159265358979323846f;\r\n\r\nglm::mat4 m( 0.0f, 1.0f, 0.0f, 0.0f,\r\n            -1.0f, 0.0f, 0.0f, 0.0f,\r\n             0.0f, 0.0f, 1.0f, 0.0f,\r\n             3.0f, 1.0f, 0.0f, 1.0f );\r\n\r\nglm::mat4 op = glm::translate( glm::mat4( 1.0f ), glm::vec3( 1.0f, 2.0f, 0.0f ) );\r\nglm::mat4 po = glm::inverse( op );\r\nglm::mat4 r  = glm::rotate( glm::mat4( 1.0f ), PI*0.5f, glm::vec3( 0.0f, 0.0f, 1.0f ) );\r\n\r\nglm::mat4 c = op * r * po;\r\n\r\n\/\/ Near expected\r\nfor( int rawID=0; rawID &lt; 4; ++rawID )\r\n{\r\n    for( int columnID=0; columnID &lt; 4; ++columnID )\r\n    {\r\n        EXPECT_NEAR( m[rawID][columnID], c[rawID][columnID], 1e-6f );\r\n    }\r\n}\r\n<\/pre><\/div><div class='clear_column'><\/div><\/p>\n<\/div>\n<p>Now, try it on points<\/p>\n<div class=\"well well-small\" style=\"text-align: center;\"><div class='content-column one_third'><p class=\"ql-center-displayed-equation\" style=\"line-height: 116px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/ql-cache\/quicklatex.com-7a3bc6d58bb560df2973dbb9f2e25b1a_l3.png\" height=\"116\" width=\"219\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; &#38;&#32;&#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#77;&#125;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#45;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#48;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#92;&#92; &#51;&#32;&#38;&#32;&#49;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#92;&#92; &#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#71;&#125; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#102;&#114;&#97;&#99;&#123;&#52;&#125;&#123;&#51;&#125;&#32;&#38;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#52;&#125;&#123;&#51;&#125;&#32;&#38;&#32;&#48;&#32;&#38;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#98;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#125; &#38;&#32;&#92;&#109;&#115;&#112;&#97;&#99;&#101;&#123;&#53;&#109;&#117;&#125; &#123;&#92;&#99;&#111;&#108;&#111;&#114;&#123;&#109;&#121;&#79;&#125;&#32;&#92;&#98;&#105;&#103;&#108;&#091;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#45;&#49;&#36;&#125;&#093;&#123;&#36;&#92;&#102;&#114;&#97;&#99;&#123;&#53;&#125;&#123;&#51;&#125;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#49;&#36;&#125;&#093;&#123;&#36;&#92;&#102;&#114;&#97;&#99;&#123;&#55;&#125;&#123;&#51;&#125;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#48;&#36;&#125;&#093;&#123;&#36;&#48;&#36;&#125;&#32;&#38; &#92;&#109;&#97;&#107;&#101;&#98;&#111;&#120;&#091;&#92;&#119;&#105;&#100;&#116;&#104;&#111;&#102;&#123;&#36;&#48;&#36;&#125;&#093;&#123;&#36;&#49;&#36;&#125; &#92;&#101;&#110;&#100;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125; &#92;&#109;&#115;&#112;&#97;&#99;&#101;&#123;&#53;&#109;&#117;&#125; &#92;&#98;&#105;&#103;&#114;&#093;&#125; &#92;&#101;&#110;&#100;&#123;&#97;&#108;&#105;&#103;&#110;&#42;&#125; \" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/div><br \/>\n<div class='content-column two_third last_column'><pre class=\"lang:default decode:true \">glm::mat4 m( 0.0f, 1.0f, 0.0f, 0.0f,\r\n            -1.0f, 0.0f, 0.0f, 0.0f,\r\n             0.0f, 0.0f, 1.0f, 0.0f,\r\n             3.0f, 1.0f, 0.0f, 1.0f );\r\n\r\nglm::vec4 a( 1.0f, 2.0f, 0.0f, 1.0f );\r\nglm::vec4 b( 4.0f\/3.0f, 4.0f\/3.0f, 0.0f, 1.0f );\r\nglm::vec4 c( 1.0f, 2.0f, 0.0f, 1.0f );\r\nglm::vec4 d( 5.0f\/3.0f, 7.0f\/3.0f, 0.0f, 1.0f );\r\n\r\nEXPECT_EQ( c, m * a );\r\n\r\nglm::vec4 computed = m * b;\r\n\/\/ Near expected\r\nfor( int columnID=0; columnID &lt; 4; ++columnID )\r\n{\r\n    EXPECT_NEAR( d[columnID], computed[columnID], 1e-6f );\r\n}\r\n<\/pre><\/div><div class='clear_column'><\/div><\/p>\n<\/div>\n<p>I leave you the care of computing C and you see we have a good result.<\/p>\n<p>Our solution is easy to understand and intuitive, moreover it demands only one multiplication.<\/p>\n<p>For your information, one last diagram:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-197 size-full\" src=\"http:\/\/mouca.fr\/wordpress\/wp-content\/uploads\/2018\/03\/all_rotate.png\" alt=\"\" width=\"497\" height=\"619\" \/><\/p>\n<p>To conclude, Our HRT matrices can be composed and cascaded: this is an important subject which helps us when we try to use them into scene graph.<\/p>\n<h2>Conclusion<\/h2>\n<div class=\"alert alert-success\" role=\"alert\">\n<p>We saw :<\/p>\n<ul>\n<li>A definition of matrix with homogeneous coordinates<\/li>\n<li>their main shapes and how to create them<\/li>\n<li>The composition<\/li>\n<\/ul>\n<\/div>\n<p>Here we have all information to use them into scene graph.<br \/>\nBut, I want to speak about quaternions before: <a href=\"http:\/\/mouca.fr\/wordpress\/index.php?p=187\">! Wait for the translation !<\/a><!-- Matrice, Quaternion et graphe de sc\u00e8ne - Partie 2 --><br \/>\nIf you don&#8217;t need them: <a href=\"http:\/\/mouca.fr\/wordpress\/index.php?p=200\">! Soon !<\/a><!-- Matrice, Quaternion et graphe de sc\u00e8ne - Partie 3 --><\/p>\n<p>Thanks for reading!<\/p>\n<p>Don&#8217;t hesitate to shared, post a comment\/fix in order to make it a dynamic tools !<\/p>\n<h2>References<\/h2>\n<p><a href=\"https:\/\/fr.wikipedia.org\/wiki\/Produit_matriciel\">Wikipedia : Produit matriciel<\/a><br \/>\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Transformation_matrix\">Wikipedia : Transformation matrix<\/a><br \/>\n<a href=\"https:\/\/fr.wikipedia.org\/wiki\/Matrice_de_passage\">Wikipedia : Matrice de passage<\/a><br \/>\n<a href=\"http:\/\/www.opengl-tutorial.org\/beginners-tutorials\/tutorial-3-matrices\/\">www.opengl-tutorial.org &#8211; Tutorial 3 : Matrices<\/a><br \/>\n<a href=\"http:\/\/morpheo.inrialpes.fr\/people\/Boyer\/Teaching\/RICM\/c3.pdf\">Les transformations g\u00e9om\u00e9triques du plan<\/a><br \/>\n<a href=\"http:\/\/www.inf.ed.ac.uk\/teaching\/courses\/cg\/lectures\/cg3_2013.pdf\">University of Edinburgh &#8211; Transformations &#8211; Taku Komura<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi everyone, today I want to speak about math, simply if possible, because the topic is about matrix &amp; quaternion. The main goal of this series of posts is to use them correctly inside an applied case: the scene graph and how to compute modelview-projection. Preface I want my approach to be more recreational than<\/p>\n<p><a class=\"button\" href=\"http:\/\/mouca.fr\/wordpress\/en\/2018\/05\/22\/matrix-quaternion-and-scene-graph-part1\/\" title=\"More\">  Read More \u2192<\/a><\/p>\n","protected":false},"author":2,"featured_media":267,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[21,23,25,27,29,31,38],"class_list":["post-252","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-applied_mathematics","tag-c-en","tag-glm-en","tag-homogene-en","tag-homothetie-en","tag-matrice-en","tag-quaternion-en","tag-scene-graph"],"_links":{"self":[{"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/posts\/252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/comments?post=252"}],"version-history":[{"count":29,"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/posts\/252\/revisions"}],"predecessor-version":[{"id":264,"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/posts\/252\/revisions\/264"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/media\/267"}],"wp:attachment":[{"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/media?parent=252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/categories?post=252"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mouca.fr\/wordpress\/wp-json\/wp\/v2\/tags?post=252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}