Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've got 3 points in space that define a triangle. I've also got a vertex buffer made up of three vertices, that also represent a triangle that I will refer to as a "model".

How can I can I find the matrix M that will transform vertex in my buffer to those 3 points in space ?

For example, let's say my three points A, B, C are at locations:

A.x = 10, A.y = 16, A.z = 8
B.x = 12, B.y = 11, B.z = 1
C.x = 19, C.y = 12, C.z = 3

given these coordinates how can I build a matrix that will translate and rotate my model such that both triangles have the exact same world space ? That is, I want the first vertex in my triangle model to have the same coordinates as A, the second to have the same coordinates as B, and same goes for C.

nb: I'm using instanced rendering so I can't just give each vertex the same position as my 3 points. I have a set of three points defining a triangle, and only three vertices in my vertex buffer.

share|improve this question

1 Answer

Do the transformations algebraically with a matrix of unknowns, set the result equal to the desired result. This gives you a system of linear equations, solve it, now you have a plug in formula for making such a matrix.

For translating from the points A, B and C to F, G, and H you'll get: quickmath.com

Result image, in case the link breaks:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["f=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &copy; 2013 stack exchange inc; \r\n                user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc-wiki</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"footer-flair\">\r\n                <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" class=\"cc-wiki-link\"></a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2013.5.17.690\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\"", "\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &copy; 2013 stack exchange inc; \r\n                user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc-wiki</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"footer-flair\">\r\n                <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" class=\"cc-wiki-link\"></a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2013.5.17.690\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Game Development Stack Exchange works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </noscript>\r\n    <script type=\"text/javascript\">var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-5620270-24']);\r\n        _gaq.push(['_s"], "copyright__copyright__copyright": ["t the result equal to the desired result. This gives you a system of linear equations, solve it, now you have a plug in formula for making such a matrix.\n\nFor translating from the points A, B and C to F, G, and H you'll get: quickmath.com\n\nResult image, in case the link breaks:\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}